atn832 / fake_cloud_firestore

BSD 2-Clause "Simplified" License
119 stars 93 forks source link

Feature/fix aggregate issue with converted queries #291

Closed ming-chu closed 8 months ago

ming-chu commented 8 months ago

This PR has fixed the aggregate query problem on converted queries. https://github.com/atn832/fake_cloud_firestore/pull/290#discussion_r1445569625 The error log would be like:

type 'Movie' is not a subtype of type 'Map<String, dynamic>' in type cast
package:fake_cloud_firestore/src/fake_aggregate_query.dart 34:56   FakeAggregateQuery._getAggregateQuerySnapshotPlatform.<fn>
dart:_internal                                                     ListIterator.moveNext
package:fake_cloud_firestore/src/fake_aggregate_query.dart 107:27  FakeAggregateQuery.buildAggregateQueryResponseList
package:fake_cloud_firestore/src/fake_aggregate_query.dart 37:12   FakeAggregateQuery._getAggregateQuerySnapshotPlatform
package:fake_cloud_firestore/src/fake_aggregate_query.dart 21:22   FakeAggregateQuery.get
ming-chu commented 8 months ago

@atn832 Thanks for the review. I just pushed the new commit according to the comments. Please let me know if I missed any :)

atn832 commented 8 months ago

I published your fix to https://pub.dev/packages/fake_cloud_firestore/changelog#247.

I also switched to Dart 3 and used pattern matching to rewrite getAggregateFieldName: https://github.com/atn832/fake_cloud_firestore/commit/f277193d98665292dc929728dde45a465aeaeefd

https://dart.dev/language/patterns#switch-statements-and-expressions