Closed graywolf-at-work closed 4 years ago
The DB.Query documentation says, "The args are for any placeholder parameters in the query." In SQL, "placeholder parameters" are placeholders for data, not commands (SELECT
, UDPATE
, etc.) or identifiers (table name, index name, column name, etc.) -- they're not a mechanism for arbitrary text replacement.
In your example, $1
is taking the place of an identifier: the table name. That's not allowed, so you're getting a syntax error.
I'm just an observer here, not one of maintainers, but I thought I'd jump in -- this has tripped me up in the past too :)
What @akshayjshah said makes sense :/
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Using the pq adapter (
github.com/lib/pq
) and database/sql I've tried dropping a table:Documentation ( https://godoc.org/database/sql#DB.Query ) does not suggested that this should not work.
What did you expect to see?
What did you see instead?