From 405e04009c1550dc6897b207ae3a63ad274c6de5 Mon Sep 17 00:00:00 2001 From: Russell Wheatley Date: Wed, 3 Jun 2020 13:57:07 +0100 Subject: [PATCH] fix(firestore): update isEqual API to check collection path equality (#3738) * fix(firestore): update isEqual check * test(firestore): test isEqual condition Co-authored-by: Mike Diarmid [publish] --- packages/firestore/e2e/Query/isEqual.e2e.js | 11 +++++++++++ packages/firestore/lib/FirestoreQuery.js | 1 + tests/e2e/mocha.opts | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/firestore/e2e/Query/isEqual.e2e.js b/packages/firestore/e2e/Query/isEqual.e2e.js index 0a0c308d90..4d35cfab20 100644 --- a/packages/firestore/e2e/Query/isEqual.e2e.js +++ b/packages/firestore/e2e/Query/isEqual.e2e.js @@ -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)', () => { diff --git a/packages/firestore/lib/FirestoreQuery.js b/packages/firestore/lib/FirestoreQuery.js index cca30d88b2..72362fac45 100644 --- a/packages/firestore/lib/FirestoreQuery.js +++ b/packages/firestore/lib/FirestoreQuery.js @@ -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; diff --git a/tests/e2e/mocha.opts b/tests/e2e/mocha.opts index f280d7f28d..23592e0f10 100644 --- a/tests/e2e/mocha.opts +++ b/tests/e2e/mocha.opts @@ -43,4 +43,4 @@ ../packages/messaging/e2e/*.e2e.js -../packages/firestore/e2e/*.e2e.js +../packages/firestore/e2e/**/*.e2e.js