Skip to content

Crash on query with predicate using long attributes. #102

Description

@matsunanaro

Describe the bug
Crash on query with predicate using long attributes.

Our app was making a query for a time period represented by two int64/long attributes in Unix Epoch Time, i.e milliseconds since 1970 Jan 1. However, it crashed with the following stack:

I/flutter (11304): onChange -- cubit: GlucoseQueryBloc, change: Change { currentState: GlucoseQueryLoading(), nextState: GlucoseQueryFailure: Failed to query database: Error querying Couchbase repository: CouchBaseRepositoryException: Error querying Couchbase repository: PlatformException(error, java.lang.Long cannot be cast to java.lang.Integer, null, java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
I/flutter (11304): 	at com.saltechsystems.couchbase_lite.QueryJson.inflateExpressionFromArray(QueryJson.java:361)
I/flutter (11304): 	at com.saltechsystems.couchbase_lite.QueryJson.inflateExpressionFromArray(QueryJson.java:528)
I/flutter (11304): 	at com.saltechsystems.couchbase_lite.QueryJson.inflateExpressionFromArray(QueryJson.java:519)
I/flutter (11304): 	at com.saltechsystems.couchbase_lite.QueryJson.inflateWhere(QueryJson.java:321)
I/flutter (11304): 	at com.saltechsystems.couchbase_lite.QueryJson.toCouchbaseQuery(QueryJson.java:114)
I/flutter (11304): 	at com.saltechsystems.couchbase_lite.CouchbaseLitePlugin$JSONCallHandler.onMethodCall(CouchbaseLitePlugin.java:708)
I/flutter (11304): 	at io.flutter.plugin.common.MethodCha

To Reproduce
Simply make a query with a long attribute in its predicate

Expected behavior
It seems that the code couldn't handle long on Android. However, it was working fine with iOS implementation.

Smartphone

  • Device: Pixel 2 API 29 android-x86 simulator
  • OS: Android 10

Additional context
According to the official document from Flutter here, a Long object is used in Java when its representation in Dart is an integer with > 32 bits.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions