2
0

Update Rows.Scan documentation to reflect reality.

Previously, the Scan documentation stated that scanning into a []byte
will skip the decoding process and directly copy the raw bytes received
from PostgreSQL.

This has not been true for at least 2 months. It is also undesirable
behavior in some cases such as a binary formatted jsonb. In that case
the '1' prefix needs to be stripped to have valid JSON. If the raw
bytes are desired this can easily be accomplished by scanning into
pgtype.GenericBinary or using Rows.RawValues.

In light of the fact that the new behavior is superior, and that it has
been in place for a significant amount of time, I have decided to
document the new behavior rather than change back to the old behavior.
This commit is contained in:
Jack Christensen
2020-09-05 11:19:51 -05:00
parent 5b06f03d0a
commit 2ec377350b
4 changed files with 48 additions and 3 deletions
+1 -2
View File
@@ -42,8 +42,7 @@ type Rows interface {
// Scan reads the values from the current row into dest values positionally.
// dest can include pointers to core types, values implementing the Scanner
// interface, []byte, and nil. []byte will skip the decoding process and directly
// copy the raw bytes received from PostgreSQL. nil will skip the value entirely.
// interface, and nil. nil will skip the value entirely.
Scan(dest ...interface{}) error
// Values returns the decoded row values.