Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v5] Check paths in Query.isEqual #2738

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/modules/firestore/Query.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ export default class Query {
return false;
}

if (
this._referencePath.relativeName !==
otherQuery._referencePath.relativeName
) {
return false;
}

if (this._fieldFilters.length !== otherQuery._fieldFilters.length) {
return false;
}
Expand Down
14 changes: 13 additions & 1 deletion tests/e2e/firestore/query.e2e.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('firestore()', () => {
describe('Query', () => {
describe('isEqual()', () => {
it(`returns true if two Queries have the same .where and .orderBy calls`, () => {
it(`returns true if two Queries for the same collection have the same .where and .orderBy calls`, () => {
const ref1 = firebase
.firestore()
.collection('foo')
Expand All @@ -17,6 +17,18 @@ describe('firestore()', () => {
should.equal(ref1.isEqual(ref2), true);
});

it(`returns false if the two Queries are for different collections`, () => {
const ref1 = firebase
.firestore()
.collection('foo')
.where('bar', '==', true);
const ref2 = firebase
.firestore()
.collection('baz')
.where('bar', '==', true);
should.equal(ref1.isEqual(ref2), false);
});

it(`returns false if two Queries have different number of .where calls`, () => {
const ref1 = firebase
.firestore()
Expand Down