Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholders for OFFSET or LIMIT are not supported #174

Closed
linuxerwang opened this issue Oct 20, 2013 · 4 comments
Closed

Placeholders for OFFSET or LIMIT are not supported #174

linuxerwang opened this issue Oct 20, 2013 · 4 comments

Comments

@linuxerwang
Copy link

This gives error:

    rows, err := db.Query("SELECT * FROM a LIMIT ? OFFSET ?", 100, 2)

2013/10/20 11:08:32 error querying database: pq: syntax error at or near "OFFSET"
2013/10/20 11:08:32 http: panic serving 127.0.0.1:39992: runtime error: invalid memory address or nil pointer dereference

This works fine:

    rows, err := db.Query("SELECT * FROM a LIMIT 100 OFFSET 2")

According to the doc in database/sql, "The args are for any placeholder parameters in the query." So I think LIMIT/OFFSET should also be supported.

@johto
Copy link
Contributor

johto commented Oct 20, 2013

What happens if you use PostgreSQL native $n syntax for the placeholders? See the example here: http://godoc.org/github.com/lib/pq

@linuxerwang
Copy link
Author

$n works fine. Thanks!

But I still think that ? should also be supported since it's the go standard.

@kisielk
Copy link
Contributor

kisielk commented Oct 20, 2013

There is no standard for placeholders in Go, it depends on the database driver. Currently pq passes the query directly to Postgres, which doesn't support the ? placeholders.

@kisielk kisielk closed this as completed Oct 20, 2013
@Lewiscowles1986
Copy link

TLDR; pq is stupid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants