You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a minor usage discrepancy between the SQLInterface wiki page and the documentation of the database/sql package when illustrating variables replacement:
From the wiki:
db.Query("SELECT name FROM users WHERE age = $1", age)
From the examples in the database/sql/example_test.go:21 (other examples affected too):
db.QueryContext(ctx, "SELECT name FROM users WHERE age=?", age)
I think all examples should use the same pattern as the wiki to avoid confusion
The text was updated successfully, but these errors were encountered:
I wouldn't label it as a discrepancy. I think it's good to have different sorts of examples so that people know that both $ and ? are valid syntax. Maybe we can document somewhere the difference between $ and ?. Not sure if it is already covered somewhere.
@agnivade The $ vs ? is DB specific. Other systems use @name rather then ?NN or $NN. Some can accept both. I'm sure we could put a comment about identifiers in the wiki, and include named identifiers, ?, and $ styles, and point to specific documentation for several instances.
SQL Server
Postgresql
MySQL
Oracle
We can also adjust the usage of Query to QueryContext too.
@kardianos Hi, I'd love to give it a try for this one!
Before actually creating a pull request, I want to confirm one thing, what do you mean by "adjust the usage of Query to QueryContext"? My understanding is, you mean "Query" should be replaced by "QueryContext", am I correct?
There is a minor usage discrepancy between the SQLInterface wiki page and the documentation of the database/sql package when illustrating variables replacement:
From the wiki:
From the examples in the database/sql/example_test.go:21 (other examples affected too):
I think all examples should use the same pattern as the wiki to avoid confusion
The text was updated successfully, but these errors were encountered: