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

in functionality is buggy. #37

Closed
jperkelens opened this issue Oct 12, 2012 · 2 comments
Closed

in functionality is buggy. #37

jperkelens opened this issue Oct 12, 2012 · 2 comments
Labels

Comments

@jperkelens
Copy link
Contributor

Example:
{ 'field1.equals' : val, 'field2.in: [val2, val3] } will produce 'SELECT * from table where field1 = $1 AND field2 IN ($1, $2, $3)

@backhand
Copy link
Contributor

I've uncovered this bug as well - a workaround is to place the in/nin predicate first, i.e. like this:
{ 'field2.in: [val2, val3], 'field1.equals' : val }

The bug is caused by the utils.quote function which doesn't take into account that previous outValues are "taken" by previous operators. By placing the in/nin predicate first, the outValues correspond to the values actually meant for that operator. This probably won't make sense unless you check the actual code - see statements.js:buildOperator and utils.js:quote :)

backhand added a commit to backhand/FastLegS that referenced this issue Jan 29, 2013
Bug: When an IN/NOT IN predicate is not the first to be added, the
statements.js:buildOperator function includes the whole outValues array
as values.

How to reproduce:
See the tests added. These will fail before this fix.

Fix:
The utils.js:quote function now takes the value being added as third
parameter. When quoting an IN/NOT IN operator, the valuePos array
starts at the correct index (outValues.length - value.length + 1).
thadclay added a commit that referenced this issue Jan 30, 2013
@thadclay
Copy link
Collaborator

Fixed in #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants