Skip to content

Commit df36a24

Browse files
author
Brian Chen
authored
Check for converter in Query.isEqual() (#3181)
1 parent 0fac7bd commit df36a24

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/firestore/src/api/database.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,9 @@ export class Query<T = firestore.DocumentData> implements firestore.Query<T> {
16481648
throw invalidClassError('isEqual', 'Query', 1, other);
16491649
}
16501650
return (
1651-
this.firestore === other.firestore && this._query.isEqual(other._query)
1651+
this.firestore === other.firestore &&
1652+
this._query.isEqual(other._query) &&
1653+
this._converter === other._converter
16521654
);
16531655
}
16541656

packages/firestore/test/integration/api/database.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,5 +1374,23 @@ apiDescribe('Database', (persistence: boolean) => {
13741374
expect(usersCollection!.isEqual(db.doc('users/user1'))).to.be.true;
13751375
});
13761376
});
1377+
1378+
it('checks converter when comparing with isEqual()', () => {
1379+
return withTestDb(persistence, async db => {
1380+
const postConverter2 = { ...postConverter };
1381+
1382+
const postsCollection = db
1383+
.collection('users/user1/posts')
1384+
.withConverter(postConverter);
1385+
const postsCollection2 = db
1386+
.collection('users/user1/posts')
1387+
.withConverter(postConverter2);
1388+
expect(postsCollection.isEqual(postsCollection2)).to.be.false;
1389+
1390+
const docRef = db.doc('some/doc').withConverter(postConverter);
1391+
const docRef2 = db.doc('some/doc').withConverter(postConverter2);
1392+
expect(docRef.isEqual(docRef2)).to.be.false;
1393+
});
1394+
});
13771395
});
13781396
});

0 commit comments

Comments
 (0)