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

Parameters $0$1 in generated query: postgresql barfs #4

Open
raarts opened this issue Nov 10, 2015 · 0 comments
Open

Parameters $0$1 in generated query: postgresql barfs #4

raarts opened this issue Nov 10, 2015 · 0 comments

Comments

@raarts
Copy link

raarts commented Nov 10, 2015

Here's my code:

contacts.publish('contact', function(){ return contacts.select('id', 'firstname', 'lastname') .where('id != ?', 1) .order('firstname DESC') .limit(100); });

The query sent to postgres from my app is:

SELECT id, firstname, lastname FROM contact WHERE id != $1 ORDER BY firstname DESC LIMIT 100;

But postgres says:

ERROR: there is no parameter $1 at character 58

If I recode as follows:

contacts.publish('contact', function(){ return contacts.select('id', 'firstname', 'lastname') .where("id != '1'") .order('firstname DESC') .limit(100); });
I get:

ERROR: syntax error at or near "$1" at character 54 SELECT id, firstname, lastname FROM contact WHERE $0$1id != '1' ORDER BY firstname DESC LIMIT 100;

What's up with the positionals, they are inserted deliberately but postgres doesn't like them. I must be missing something

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

1 participant