Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Next(): populate Row with []byte instead of string, as per driver doc
Fix on behalf of bradfitz, see http://golang.org/pkg/database/sql/driver/#Rows
- Loading branch information
4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this change, it causes TEXT values to be returned as []byte instead of strings. As far as I know the postgresql driver returns a string for TEXT columns.
4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I'm told that postgres does return a byte slice too in that case, so ignore me. In which case would a string be passed to sql.Scanner.Scan()?
4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, I misinformed @jobi about the Postgres driver. http://golang.org/pkg/database/sql/#Scanner implies that the value coming out could be a
string
, I wonder what are the circumstances when that could happen if not on atext
field?4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What your matters?
4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattn: Our code broke because our
Scanner.Scan
implementation was casting the value tostring
rather than[]byte
. We've updated our code to handle both, but I am having a difficult time reconciling the docs fordriver.Rows
which says, "All string values must be converted to []byte" and Scanner.Scan, which says, "The src value will be of one of the following restricted set of types" and lists "string" among them.4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joeshaw @jobi do you have any sugguetion to change/fix?
4a7ad32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattn I'm not sure, we worked around it long ago. It seems like maybe something we should get clarification on from the Go developers.