Repository navigation
Convert DocumentReference values in Firestore document data - #110
Open
abdul10ahad wants to merge 1 commit into
Open
abdul10ahad wants to merge 1 commit into
abdul10ahad wants to merge 1 commit into
Conversation
DocumentSnapshot.data() left a com.google.firebase.firestore.DocumentReference as a raw Kotlin object, which SkipBridge cannot convert in a native (Fuse) app, so reading any document with a reference field crashed on Android. Convert it to the module's DocumentReference, like Timestamp and GeoPoint. Fixes skiptools#109.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #109.
DocumentSnapshot.data()crashes a native (Fuse) Android app when the document has a field of type reference:firestoreDeepSwift(value:)returns acom.google.firebase.firestore.DocumentReferenceas a raw Kotlin object, andAnyBridging.fromJavaObjecthas no Swift type for it when the dictionary crosses the bridge.if let gp = value as? com.google.firebase.firestore.GeoPoint { return GeoPoint(latitude: gp.latitude, longitude: gp.longitude) } + if let ref = value as? com.google.firebase.firestore.DocumentReference { + return DocumentReference(ref: ref) + }The reference becomes the module's own
DocumentReference, the same wayTimestampandGeoPointare handled. Maps and collections recurse through this function, so nested references are covered.Evidence
Standalone Skip Fuse app reading a document with a top-level and a nested reference from a local Firestore emulator (details in #109), arm64 emulator, API 37. This change was applied on top of 0.21.1 for the test.
One run per side. Not tested: references inside arrays, a transpiled (Lite) app, and this repository's test suite. No test added. The repository has Firestore tests, but I have not worked out whether they can exercise the native bridge path where this crash happens; glad to add one if you can point me at the right place.