Skip to content

Commit 6bf1b0b

Browse files
committed
Add database/sql to overview of scanning
1 parent 14bda65 commit 6bf1b0b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pgtype/doc.go

+6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ plan for scanning into the Go value. A Codec will support scanning into one or m
164164
are interfaces rather than explicit types. For example, PointCodec can use any Go type that implements the PointScanner
165165
and PointValuer interfaces.
166166
167+
If a Go value is not supported directly by a Codec then Map will try see if it is a sql.Scanner. If is then that
168+
interface will be used to scan the value. Most sql.Scanners require the input to be in the text format (e.g. UUIDs and
169+
numeric). However, pgx will typically have received the value in the binary format. In this case the binary value will be
170+
parsed, reencoded as text, and then passed to the sql.Scanner. This may incur additional overhead for query results with
171+
a large number of affected values.
172+
167173
If a Go value is not supported directly by a Codec then Map will try wrapping it with additional logic and try again.
168174
For example, Int8Codec does not support scanning into a renamed type (e.g. type myInt64 int64). But Map will detect that
169175
myInt64 is a renamed type and create a plan that converts the value to the underlying int64 type and then passes that to

0 commit comments

Comments
 (0)