Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-andersen committed Aug 23, 2023
1 parent 296649d commit ccffd19
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
50 changes: 40 additions & 10 deletions dev/src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,9 @@ export class AggregateQuery<
*
* @return A promise that will be resolved with the results of the query.
*/
get(): Promise<AggregateQuerySnapshot<AggregateSpecType>> {
get(): Promise<
AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>
> {
return this._get();
}

Expand All @@ -3202,7 +3204,9 @@ export class AggregateQuery<
*/
_get(
transactionId?: Uint8Array
): Promise<AggregateQuerySnapshot<AggregateSpecType>> {
): Promise<
AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>
> {
// Capture the error stack to preserve stack tracing across async calls.
const stack = Error().stack!;

Expand Down Expand Up @@ -3241,7 +3245,11 @@ export class AggregateQuery<
const data = this.decodeResult(proto.result);
callback(
undefined,
new AggregateQuerySnapshot<AggregateSpecType>(this, readTime, data)
new AggregateQuerySnapshot<
AggregateSpecType,
AppModelType,
DbModelType
>(this, readTime, data)
);
} else {
callback(Error('RunAggregationQueryResponse is missing result'));
Expand Down Expand Up @@ -3390,8 +3398,16 @@ export class AggregateQuery<
/**
* The results of executing an aggregation query.
*/
export class AggregateQuerySnapshot<T extends firestore.AggregateSpec>
implements firestore.AggregateQuerySnapshot<T>
export class AggregateQuerySnapshot<
AggregateSpecType extends firestore.AggregateSpec,
AppModelType,
DbModelType
> implements
firestore.AggregateQuerySnapshot<
AggregateSpecType,
AppModelType,
DbModelType
>
{
/**
* @private
Expand All @@ -3403,13 +3419,21 @@ export class AggregateQuerySnapshot<T extends firestore.AggregateSpec>
* query.
*/
constructor(
private readonly _query: AggregateQuery<T>,
private readonly _query: AggregateQuery<
AggregateSpecType,
AppModelType,
DbModelType
>,
private readonly _readTime: Timestamp,
private readonly _data: firestore.AggregateSpecData<T>
private readonly _data: firestore.AggregateSpecData<AggregateSpecType>
) {}

/** The query that was executed to produce this result. */
get query(): firestore.AggregateQuery<T> {
get query(): firestore.AggregateQuery<
AggregateSpecType,
AppModelType,
DbModelType
> {
return this._query;
}

Expand All @@ -3429,7 +3453,7 @@ export class AggregateQuerySnapshot<T extends firestore.AggregateSpec>
* @returns The results of the aggregations performed over the underlying
* query.
*/
data(): firestore.AggregateSpecData<T> {
data(): firestore.AggregateSpecData<AggregateSpecType> {
return this._data;
}

Expand All @@ -3444,7 +3468,13 @@ export class AggregateQuerySnapshot<T extends firestore.AggregateSpec>
* @return `true` if this object is "equal" to the given object, as
* defined above, or `false` otherwise.
*/
isEqual(other: firestore.AggregateQuerySnapshot<T>): boolean {
isEqual(
other: firestore.AggregateQuerySnapshot<
AggregateSpecType,
AppModelType,
DbModelType
>
): boolean {
if (this === other) {
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions dev/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ export class Transaction implements firestore.Transaction {
AppModelType,
DbModelType
>
): Promise<AggregateQuerySnapshot<AggregateSpecType>>;
): Promise<
AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>
>;

/**
* Retrieve a document or a query result from the database. Holds a
Expand Down Expand Up @@ -157,7 +159,7 @@ export class Transaction implements firestore.Transaction {
): Promise<
| DocumentSnapshot<AppModelType, DbModelType>
| QuerySnapshot<AppModelType, DbModelType>
| AggregateQuerySnapshot<AggregateSpecType>
| AggregateQuerySnapshot<AggregateSpecType, AppModelType, DbModelType>
> {
if (!this._writeBatch.isEmpty) {
throw new Error(READ_AFTER_WRITE_ERROR_MSG);
Expand Down
5 changes: 1 addition & 4 deletions dev/system-test/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2551,10 +2551,7 @@ describe('Aggregates', () => {
let randomCol: CollectionReference;

beforeEach(() => {
randomCol = getTestRoot({
projectId: "cicd-demo-e9b7d",
databaseId: "db01"
});
randomCol = getTestRoot();
firestore = randomCol.firestore;
});

Expand Down
2 changes: 1 addition & 1 deletion dev/test/aggregateQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as chaiAsPromised from 'chai-as-promised';
import {setTimeoutHandler} from '../src/backoff';
use(chaiAsPromised);

describe.only('aggregate query interface', () => {
describe('aggregate query interface', () => {
let firestore: Firestore;

beforeEach(() => {
Expand Down

0 comments on commit ccffd19

Please sign in to comment.