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

whereIn() with empty array #477

Closed
bblack opened this issue Sep 11, 2014 · 2 comments
Closed

whereIn() with empty array #477

bblack opened this issue Sep 11, 2014 · 2 comments

Comments

@bblack
Copy link
Contributor

@bblack bblack commented Sep 11, 2014

Consider the call:

knex('people').whereIn('name', names)

If names is an empty array, the generated query will have invalid syntax:

select * from "people" where "name" in ()

Can knex support empty arrays for whereIn()? e.g. by generating something like

select * from "people" where false
@tgriesser tgriesser closed this in 5280e6e Oct 1, 2014
@tgriesser
Copy link
Member

@tgriesser tgriesser commented Oct 1, 2014

Added, also added .orWhereIn('name', []) to yield select * from 'people' where true

@runeh
Copy link
Contributor

@runeh runeh commented Oct 20, 2014

It seems like sqlite doesn't support the "where false" syntax. This query:

db('users').whereIn('id', []);

Worked on my sqlite db in knex 0.6.22, but fails in 0.7.x . The error is:

SQLITE_ERROR: no such column: false

Not sure if I'm reading this right, but doesn't seem to support bools here: https://www.sqlite.org/syntax/expr.html

@tgriesser tgriesser reopened this Oct 20, 2014
runeh added a commit to runeh/knex that referenced this issue Oct 20, 2014
tgriesser added a commit that referenced this issue Feb 25, 2015
* SQLite uses integers, not booleans
* whereIn/whereNotIn with empty array uses a boolean
* Closes #477
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.