in functionality is buggy. #37

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

3 participants

@jperkelens

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

@backhand

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 backhand added a commit to backhand/FastLegS that referenced this issue Jan 29, 2013
@backhand backhand Fix and tests for issue #37
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).
fea7b19
@thadclay
Didit Technology Team member

Fixed in #48

@thadclay thadclay closed this Jan 30, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment