Why does IN operator yields syntax error in this example?

I’m using CBL 3.0.1, working in Objective-C. I’m compiling queries by specifying a query string and then calling CBLDatabase’s -createQuery:error: method. When I try to compile this query:

SELECT customer_id, name FROM _default WHERE customer_id IN ["a", "b", "c"] ORDER BY lower(name) ASC

I end up getting a syntax error (character 61 is the opening square bracket):

N1QL syntax error near character 61

This query looks correct to my reading of the N1QL docs. The same error occurs when I use a variable instead of the literal list. What am I doing wrong?

You just need to put ( customer_id IN [“a”, “b”, “c”] ) in the paren, because of the limitation of the current grammar parser.

Unfortunately, using parentheses around the IN expression does not help.

SELECT customer_id, name FROM _default WHERE ( customer_id IN ["one", "two", "three"] ) ORDER BY lower(name) ASC

yields the same parser error (character 63 is the opening square bracket):

N1QL syntax error near character 63

I cannot repro it in v3.2. Could you try it on newer release?

Works with v3.2.1 on my end. The bug was fixed between v3.0.1 and the latest.

Can confirm that the parentheses are required for the parser to grok the IN expression.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.