[firestore v1] runAggregationQuery appears to be broken
jimmyff opened this issue · 1 comments
Using the latest version 10.1.0
and looking at code on master branch it appears runAggregationQuery is broken. I'm looking at the test file and I believe the test should not be passing too. I'm not entirely sure how to set this beast of a package up locally to test though!
Here is my code:
final req = RunAggregationQueryRequest(
structuredAggregationQuery: StructuredAggregationQuery(
aggregations: [Aggregation(alias: 'count', count: Count())],
structuredQuery: query,
),
);
final result = await firestoreApi.projects.databases.documents
.runAggregationQuery(req, ServerConfig.documentsPath);
This is the error I'm getting:
Counting Instance of 'RunAggregationQueryRequest'
type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast
#0 ProjectsDatabasesDocumentsResource.runAggregationQuery (package:googleapis/firestore/v1.dart:1580:19)
<asynchronous suspension>
#1 FirestoreDocumentLoader.count (package:cloud_functions_core/src/firestore.dart:186:11)
<asynchronous suspension>
#2 main (file:///Users/jimmyff/dev/foobar/esc_cloud_functions/cloud_functions_cli/bin/scripts/count_scorecards.dart:47:13)
I was following the example in the test file:
https://github.com/google/googleapis.dart/blob/master/test_integration/test/firestore_test.dart#L68
The test expects a List as the response however the implementation is returning RunAggregationQueryResponse which tries to cast it to a map:
return RunAggregationQueryResponse.fromJson(response_ as core.Map<core.String, core.dynamic>)
It looks like RunAggregationQueryResponse is the expected response:
https://github.com/google/googleapis.dart/blob/master/discovery/googleapis/firestore__v1.json#L1123