atn832/fake_cloud_firestore

Add support for `cloud_firestore: ^4.14.0`

Closed this issue ยท 5 comments

Looks like when the latest version of this plugin is used in combination with cloud_firestore: ^4.14.0, it no longer works as it's missing implementations for AggregateQuery.count, AggregateQuerySnapshot.getAverage etc. leading to errors like:

./.pub-cache/hosted/pub.dev/fake_cloud_firestore-2.4.6/lib/src/mock_query.dart:20:7: Error: The non-abstract class 'MockQuery'
is missing implementations for these members:
 - Query.aggregate
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class MockQuery<T extends Object?> extends FakeQueryWithParent<T> {
      ^^^^^^^^^
../.pub-cache/hosted/pub.dev/cloud_firestore-4.14.0/lib/src/query.dart:198:18: Context: 'Query.aggregate' is defined here.
  AggregateQuery aggregate(
                 ^^^^^^^^^
../.pub-cache/hosted/pub.dev/fake_cloud_firestore-2.4.6/lib/src/mock_collection_reference.dart:16:7: Error: The non-abstract
class 'MockCollectionReference' is missing implementations for these members:
 - Query.aggregate
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class MockCollectionReference<T extends Object?> extends MockQuery<T>
      ^^^^^^^^^^^^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/cloud_firestore-4.14.0/lib/src/query.dart:198:18: Context: 'Query.aggregate' is defined here.
  AggregateQuery aggregate(
                 ^^^^^^^^^
../.pub-cache/hosted/pub.dev/fake_cloud_firestore-2.4.6/lib/src/fake_aggregate_query.dart:5:7: Error: The non-abstract class
'FakeAggregateQuery' is missing implementations for these members:
 - AggregateQuery.count
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class FakeAggregateQuery implements AggregateQuery {
      ^^^^^^^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/cloud_firestore-4.14.0/lib/src/aggregate_query.dart:29:18: Context: 'AggregateQuery.count' is
defined here.
  AggregateQuery count() {
                 ^^^^^
../.pub-cache/hosted/pub.dev/fake_cloud_firestore-2.4.6/lib/src/fake_aggregate_query_snapshot.dart:3:7: Error: The non-abstract
class 'FakeAggregateQuerySnapshot' is missing implementations for these members:
 - AggregateQuerySnapshot.getAverage
 - AggregateQuerySnapshot.getSum
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class FakeAggregateQuerySnapshot implements AggregateQuerySnapshot {
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/cloud_firestore-4.14.0/lib/src/aggregate_query_snapshot.dart:25:11: Context:
'AggregateQuerySnapshot.getAverage' is defined here.
  double? getAverage(String field) => _delegate.getAverage(field);
          ^^^^^^^^^^
../.pub-cache/hosted/pub.dev/cloud_firestore-4.14.0/lib/src/aggregate_query_snapshot.dart:22:11: Context:
'AggregateQuerySnapshot.getSum' is defined here.
  double? getSum(String field) => _delegate.getSum(field);

You're right. cloud_firestore changed the API for aggregate queries in ^4.14.0. I don't know if I can work on it in the coming weeks but I'll happily review a PR if someone volunteers.

Relevant links:

@atn832 I submitted a PR for this, please feel free to check it out. #290

alternatively, we might want to furnish an implementation of noSuchMethod so this library does not break everytime firebase adds a feature.

@cedvdb good suggestion. It's used in only two places so far. I added it to the aggregate classes 203a0d0.
@ming-chu thanks for the very fast and high quality PR!

I just merged and published @ming-chu 's pull request: https://pub.dev/packages/fake_cloud_firestore/changelog#247.