Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug][Android] Dates are being incorrectly unwrapped #37

Open
ebhsgit opened this issue Aug 20, 2021 · 0 comments · May be fixed by #38
Open

[Bug][Android] Dates are being incorrectly unwrapped #37

ebhsgit opened this issue Aug 20, 2021 · 0 comments · May be fixed by #38

Comments

@ebhsgit
Copy link

ebhsgit commented Aug 20, 2021

Expected Behavior

Correct date value is parsed

Actual Behavior

The left most number is lost, causing incorrect Date value

Steps to Reproduce the Problem

async add(json: {}) {
   const db = await Firestore.initialise({})
   db.get().collection("path").add(json)
}

add({
   date: new Date(0)
})

running the above code will generate an exception

Error processing collection add in thread
    java.lang.NumberFormatException: For input string: ""
        at java.lang.Long.parseLong(Long.java:606)
        at java.lang.Long.parseLong(Long.java:636)
        at uk.co.reallysmall.cordova.plugin.firestore.JSONDateWrapper.unwrapDate(JSONDateWrapper.java:34)
        at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.fromJSON(JSONHelper.java:83)
        at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.toSettableMapInternal(JSONHelper.java:119)
        at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.toSettableJSONInternal(JSONHelper.java:113)
        at uk.co.reallysmall.cordova.plugin.firestore.JSONHelper.fromJSON(JSONHelper.java:98)
        at uk.co.reallysmall.cordova.plugin.firestore.CollectionAddHandler.handle(CollectionAddHandler.java:35)
        at uk.co.reallysmall.cordova.plugin.firestore.FirestorePlugin.execute(FirestorePlugin.java:73)
         ...
         ...

The reason is because the value is encoded as __DATE:0
JSONDateWrapper.unwrapDate() will strip 8 characters (prefixLength + 1), which return empty string.

The correct behaviour should be to strip 7 chars.

Specifications

  • Plugin version: master branch
  • Framework:
  • Framework version:
  • Operating system: Android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant