kylefarris / node-querybuilder

Node QueryBuilder Adapter for Node.js (tags: nodejs, node, mysql, active record, activerecord, querybuilder, query builder)
49 stars 19 forks source link

Allow where_in and where_not_in to have empty arrays #34

Closed Flamenco closed 6 years ago

Flamenco commented 6 years ago

I have to put many checks in my code for filters because where_in('foo',[]) will throw an error. Please consider allowing these conditions.

Flamenco commented 6 years ago
screen shot 2018-07-19 at 2 43 19 pm
kylefarris commented 6 years ago

Would you rather it just silently ignore it?

Flamenco commented 6 years ago

Yes. Ignore will be great. No need to encode in SQL.

kylefarris commented 6 years ago

This is officially fixed in the v2 branch. Beta should be out soon.

kylefarris commented 6 years ago

@Flamenco Thank you for being so active in reporting issues. A v2 Beta is officially out on NPM. If you wouldn't mind testing it, that would be very much appreciated.

You can install the beta like so:

npm i node-querybuilder@next

If you need to submit issues for it, please prefix the issue with v2Beta:

Thanks again!

Flamenco commented 6 years ago

@kylefarris I am not sure how you implemented this, but maybe instead of ignoring, replace where_in('foo', []) with false or (1=0) and where_not_in('foo', []) with true or (1=1). I am about to switch over to v2 and I have some complex queries that may have issues.