-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Expected Behavior
Batches and transactions should work
Actual Behavior
Batches and transactions fail with error like: TypeError: Instance of '(TestSerializable, SetOptions?) => Map<String, Object?>': type '(TestSerializable, SetOptions?) => Map<String, Object?>' is not a subtype of type '(Object, SetOptions?) => Map<String, Object?>'
Steps to Reproduce the Problem
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';
import 'package:json_annotation/json_annotation.dart';
part 'test.g.dart';
/// A custom JsonSerializable annotation that supports decoding objects such
/// as Timestamps and DateTimes.
/// This variable can be reused between different models
const firestoreSerializable = JsonSerializable(
converters: firestoreJsonConverters,
// The following values could alternatively be set inside your `build.yaml`
explicitToJson: true,
createFieldMap: true,
createPerFieldToJson: true,
);
@firestoreSerializable
class TestSerializable {
TestSerializable({
required this.origin,
});
final String origin;
}
@Collection<TestSerializable>('test')
final testCollectionReference = TestSerializableCollectionReference();
test() async {
testCollectionReference.doc("id1").set(TestSerializable(origin: 'regular'));
final batch = FirebaseFirestore.instance.batch();
testCollectionReference.doc("id2").batchSet(batch, TestSerializable(origin: 'batch'));
await batch.commit();
FirebaseFirestore.instance.runTransaction((transaction) async {
testCollectionReference.doc("id3").transactionSet(transaction, TestSerializable(origin: 'transaction'));
});
}- Execute test() in a flutter project where Firestore is configured
- Verify in Firestore console that test collection contains doc id1, but no id2 or id3.
Specifications
- Version: cloud_firestore_odm: 1.0.0-dev.88, cloud_firestore_odm_generator: 1.0.0-dev.89, cloud_firestore: 5.5.1
- Platform: Android, web (not tested on iOS)
rolandtolnay
Metadata
Metadata
Assignees
Labels
No labels