FirebaseExtended / firestoreodm-flutter

BSD 3-Clause "New" or "Revised" License
33 stars 9 forks source link

Typedef @Id() gets wrongly generated into the document #19

Open GyulaSipos opened 2 months ago

GyulaSipos commented 2 months ago

This is just a silly little bug, not high priority or anything at all, but I figured might as well open an issue on it.

Expected Behavior

The @Id() annotated String field does not get to be generated into the document in Firestore, even if I use a type alias like: typedef ExampleId = String;

Actual Behavior

If I write:

typedef ExampleId = String;

@firestoreSerializable
class Example {
  @Id()
  final ExampleId id;
...
}

Then I add some Example documents into the collection in Firebase, the 'id' field appears in the document, containing the dummy id, not the Firestore assigned one. So the next time, when i get the document, it gets the id wrongly assigned to the dummy id.

Steps to Reproduce the Problem

  1. Generate a document with the type of the @Id() field being a typedef for String
  2. run the code generation and create some documents with the typedef-ed Id, then read them back from Firestore
  3. notice, that the Object's id is the one you sent up and not the Firebase assigned one. Also, if you open the firestore GUI on web, you'll see the id field appear in the document

Specifications