Closed emicklei closed 10 years ago
I agree with this. I had the same problem, and from the stack overflow posts, this is a common problem.
Agreed, this cost me 30 minutes of googling.
Closing. Please re-post at http://github.com/lib/pq if there is still a problem.
@wilig - 30 minutes of googling me too.
Unlike is documented on http://golang.org/pkg/database/sql/#example_DB_Query, this driver cannot handle the "?" placeholder for query parameters. Instead the $ notation must be used. Figuring this out took me far too long while staring at:
SELECT * FROM questions WHERE id=?
pq: S:"ERROR" C:"42883" M:"operator does not exist: integer =?" H:"No operator matches the given name and argument type(s). You might need to add explicit type casts." P:"33" F:"parse_oper.c" L:"755" R:"op_error"
Eventually, I found the correct expression:
db.Query("SELECT * FROM questions WHERE id=$1", 1)