Skip to content

Commit

Permalink
Next(): populate Row with []byte instead of string, as per driver doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mpl committed Dec 5, 2013
1 parent c066df8 commit 4a7ad32
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
dest[i] = time.Time{}
}
default:
dest[i] = s
dest[i] = []byte(s)
}

}
Expand Down

7 comments on commit 4a7ad32

@jobi
Copy link

@jobi jobi commented on 4a7ad32 Apr 11, 2014

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.

@jobi
Copy link

@jobi jobi commented on 4a7ad32 Apr 11, 2014

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()?

@joeshaw
Copy link
Contributor

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 a text field?

@mattn
Copy link
Owner

@mattn mattn commented on 4a7ad32 Apr 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What your matters?

@joeshaw
Copy link
Contributor

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 to string rather than []byte. We've updated our code to handle both, but I am having a difficult time reconciling the docs for driver.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.

@mattn
Copy link
Owner

@mattn mattn commented on 4a7ad32 Mar 27, 2015

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?

@joeshaw
Copy link
Contributor

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.

Please sign in to comment.