Skip to content

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

@raarts

Description

@raarts

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions