SQL++ COLLATE NODIACRITIC doesn't work as documented

I received a report from a Kotbase user that using a SQL++ query string with COLLATE NODIACRITIC or COLLATE DIACRITIC as documented results in the error:

java.lang.IllegalStateException: Failed creating query
Caused by: CouchbaseLiteException{CouchbaseLite,23,‘N1QL syntax error near character 165
(CouchbaseLite Android v3.1.9-1@35 (CE/release, Commit/unofficial@4be996b9d781 Core/3.1.9 (5) at 2024-07-31T23:42:52.615748797Z) on Java; Android 15; sdk_gphone64_x86_64)’}
at com.couchbase.lite.N1qlQuery.prepQueryLocked(N1qlQuery.java:54)
at com.couchbase.lite.AbstractQuery.getC4QueryLocked(AbstractQuery.java:274)
at com.couchbase.lite.AbstractQuery.setParameters(AbstractQuery.java:133)
130 more
Caused by: LiteCoreException{1, 23, “N1QL syntax error near character 165”}
at com.couchbase.lite.internal.core.impl.NativeC4Query.createQuery(Native Method)
at com.couchbase.lite.internal.core.impl.NativeC4Query.nCreateQuery(NativeC4Query.java:28)
at com.couchbase.lite.internal.core.C4Query.(C4Query.java:83)
at com.couchbase.lite.internal.core.C4Query.create(C4Query.java:63)
at com.couchbase.lite.internal.core.C4Database.createN1qlQuery(C4Database.java:547)
at com.couchbase.lite.AbstractDatabase.createN1qlQuery(AbstractDatabase.java:1282)
at com.couchbase.lite.N1qlQuery.prepQueryLocked(N1qlQuery.java:53)
132 more

I tested and confirmed receiving a similar error using both the Java and Objective-C SDKs.

Also note, the documentation uses both DIACRITIC and DIACRITICS under the arguments and syntax sections, and neither of these work.

Looking at the underlying code for the QueryBuilder, I see that the JSON query syntax uses DIAC. Testing using DIAC and NODIAC in the SQL++ query string seems to work correctly.

1 Like

This looks like a documentation error. The N1QL parser in LiteCore uses DIAC. I’ll notify the documentation team.

… reported as DOC-13335.