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

positional (vs just question mark) notation in postgres #363

Closed
calvinmetcalf opened this Issue Jul 10, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@calvinmetcalf
Contributor

calvinmetcalf commented Jul 10, 2014

in certain types of queriers postgres needs positional notation ($1, $2 etc) not question mark notation, e.g.

select
    "key", "value"
from
    "_leveldown_test_db_10"
where 
    "id" in (
         select 
             max("id")
         from
             "_leveldown_test_db_10"
         where
             "key" >= ?
         group by
             "key"
     )
order by
    "key" asc limit ?

in an error, but

select
    "key", "value"
from
    "_leveldown_test_db_10"
where 
    "id" in (
         select 
             max("id")
         from
             "_leveldown_test_db_10"
         where
             "key" >= $1
         group by
             "key"
     )
order by
    "key" asc limit $2

is not

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Jul 10, 2014

All postgres queries should be converted to the correct positional notation internally just before being run, is there somewhere you're seeing where this isn't the case?

@calvinmetcalf

This comment has been minimized.

Contributor

calvinmetcalf commented Jul 10, 2014

ah so the error is that it isn't being done but should. This query, when run on my local branch that subs in postgres, has that happen, I wonder if its a bug with the stream interface?

@calvinmetcalf

This comment has been minimized.

Contributor

calvinmetcalf commented Jul 10, 2014

up putting console.log(sql.sql, sql.bindings, options); right before this line gives me

select "key", "value" from "_leveldown_test_db_10" where "id" in (select max("id") from "_leveldown_test_db_10" where "key" >= ? group by "key") order by "key" asc [ '00' ] undefined

@tgriesser tgriesser added the bug label Jul 10, 2014

@tgriesser tgriesser closed this in 521f22a Jul 10, 2014

@tgriesser tgriesser added the fixed label Jul 10, 2014

@tgriesser

This comment has been minimized.

Owner

tgriesser commented Jul 10, 2014

Yep, try the latest and it should be taken care of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment