Skip to content

Commit

Permalink
fix(firestore): update isEqual API to check collection path equality (#…
Browse files Browse the repository at this point in the history
…3738)

* fix(firestore): update isEqual check

* test(firestore): test isEqual condition

Co-authored-by: Mike Diarmid <mike.diarmid@gmail.com>
[publish]
  • Loading branch information
russellwheatley authored Jun 3, 2020
1 parent e6acaea commit 405e040
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/firestore/e2e/Query/isEqual.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,26 @@ describe('firestore().collection().isEqual()', () => {
.collection('v6')
.limit(3);

const ref1 = firebase
.firestore()
.collection('foo')
.where('bar', '==', true);
const ref2 = firebase
.firestore()
.collection('baz')
.where('bar', '==', true);

const eql1 = query.isEqual(q1);
const eql2 = query.isEqual(q2);
const eql3 = query.isEqual(q3);
const eql4 = query.isEqual(q4);
const eql5 = ref1.isEqual(ref2);

eql1.should.be.False();
eql2.should.be.False();
eql3.should.be.False();
eql4.should.be.False();
eql5.should.be.False();
});

it('returns false when not equal (expensive checks)', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/firestore/lib/FirestoreQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default class FirestoreQuery {
this._modifiers.type !== other._modifiers.type ||
this._modifiers.filters.length !== other._modifiers.filters.length ||
this._modifiers.orders.length !== other._modifiers.orders.length ||
this._collectionPath.relativeName !== other._collectionPath.relativeName ||
Object.keys(this._modifiers.options).length !== Object.keys(other._modifiers.options).length
) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/mocha.opts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@

../packages/messaging/e2e/*.e2e.js

../packages/firestore/e2e/*.e2e.js
../packages/firestore/e2e/**/*.e2e.js

0 comments on commit 405e040

Please sign in to comment.