realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

Invalid predicate: 'desc CONTAINS[c] $0': syntax error #7705

Closed Pro-55 closed 1 year ago

Pro-55 commented 1 year ago

How frequently does the bug occur?

All the time

Description

The app crashes when the query is run. We have several pojos with field public String desc;.

Stacktrace & log output

Process: in.bizanalyst.debug, PID: 25439
    java.lang.IllegalArgumentException: Illegal Argument: Invalid predicate: 'desc CONTAINS[c] $0': syntax error, unexpected descending in /tmp/realm-java/realm/realm-library/src/main/cpp/io_realm_internal_TableQuery.cpp line 512
        at io.realm.internal.TableQuery.nativeRawPredicate(Native Method)
        at io.realm.internal.TableQuery.rawPredicateWithPointers(TableQuery.java:185)
        at io.realm.RealmAnyNativeFunctionsImpl.callRawPredicate(RealmAnyNativeFunctionsImpl.java:52)
        at io.realm.internal.TableQuery.containsInsensitive(TableQuery.java:294)
        at io.realm.RealmQuery.contains(RealmQuery.java:1670)
        at io.realm.RealmQuery.contains(RealmQuery.java:1652)
        at in.bizanalyst.dao.InventoryDao.getBySubstrAndStockAvailability(InventoryDao.java:139)
        at in.bizanalyst.adapter.InventoryArrayAdapter.filterResults(InventoryArrayAdapter.java:103)
        at in.bizanalyst.adapter.InventoryArrayAdapter$InventoryFilter.publishResults(InventoryArrayAdapter.java:128)
        at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:284)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7870)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Can you reproduce the bug?

Yes, always

Reproduction Steps

Just need to trigger this query.

Version

10.11.0

What SDK flavour are you using?

Local Database only

Are you using encryption?

Yes, using encryption

Platform OS and version(s)

Android [12]

Build environment

Android Studio version: AS Chipmunk | 2021.2.1 Patch 1 Android Build Tools version: 31 Gradle version: 7.1.3

novecapa commented 1 year ago

With no internet connection, same error in Realm 10.10.1 and Gradle 7.1.2, but with internet connection the error not appear 🧐

Pro-55 commented 1 year ago

In my case I'm just accessing the local data so its not dependant on the network state.

rorbech commented 1 year ago

Hi @Pro-55. Thanks for the report. I was able to reproduce and have filed an issue in the query parser.