You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IN and NOT IN ignore list items that are not plain literals: a IN (-1, 5) misses -1 #2874
With the statement cache on, which is the default, IN (...) and NOT IN (...) ignore every list item that is not a plain literal: a negative number, an expression, a column.
vardata=[{a: -1,b: 0},{a: 5,b: 0},{a: 3,b: 3}];alasql('SELECT a FROM ? WHERE a IN (-1, 5)',[data]);// [{a: 5}]alasql('SELECT a FROM ? WHERE a IN (1 + 2, 5)',[data]);// [{a: 5}]alasql('SELECT a FROM ? WHERE a IN (b, 5)',[data]);// [{a: 5}]alasql('SELECT a FROM ? WHERE a NOT IN (-1, 5)',[data]);// [{a: -1}, {a: 3}]alasql.options.cache=false;alasql('SELECT a FROM ? WHERE a IN (-1, 5)',[data]);// [{a: -1}, {a: 5}]alasql('SELECT a FROM ? WHERE a IN (b, 5)',[data]);// [{a: 5}, {a: 3}]
Expected: the results with the cache off.
The same in 4.20.0, so not new. The cached path builds its Set from item.value of each list item (src/expression/expression.js, the two allValues lines). -1 is a unary minus node, 1 + 2 an operator and b a column, so each has no value and becomes undefined. The fix: use the Set only when every item is a literal, and compile the list otherwise.
Activity
Compile IN and NOT IN lists with non-literal items to close AlaSQL#2874
Compile IN and NOT IN lists with non-literal items to close AlaSQL#2874