Skip to content

Commit c0a34ac

Browse files
committed
Merge branch 'master' into ddb-chrome-version-warnings
2 parents e277ce8 + 2e32eeb commit c0a34ac

File tree

6 files changed

+46
-12
lines changed

6 files changed

+46
-12
lines changed

.changeset/itchy-chicken-cry.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.changeset/long-rats-walk.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.changeset/yellow-houses-happen.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/firestore': patch
3+
'firebase': patch
4+
---
5+
6+
Update the `isEqual` function for arrayUnion, arrayRemove and increment.

packages/firestore/src/lite-api/user_data_reader.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
FieldPath as PublicFieldPath,
2121
SetOptions
2222
} from '@firebase/firestore-types';
23-
import { Compat, getModularInstance } from '@firebase/util';
23+
import { Compat, deepEqual, getModularInstance } from '@firebase/util';
2424

2525
import { ParseContext } from '../api/parse_context';
2626
import { DatabaseId } from '../core/database_info';
@@ -525,13 +525,15 @@ export class ArrayUnionFieldValueImpl extends FieldValue {
525525
}
526526

527527
isEqual(other: FieldValue): boolean {
528-
// TODO(mrschmidt): Implement isEquals
529-
return this === other;
528+
return (
529+
other instanceof ArrayUnionFieldValueImpl &&
530+
deepEqual(this._elements, other._elements)
531+
);
530532
}
531533
}
532534

533535
export class ArrayRemoveFieldValueImpl extends FieldValue {
534-
constructor(methodName: string, readonly _elements: unknown[]) {
536+
constructor(methodName: string, private readonly _elements: unknown[]) {
535537
super(methodName);
536538
}
537539

@@ -549,8 +551,10 @@ export class ArrayRemoveFieldValueImpl extends FieldValue {
549551
}
550552

551553
isEqual(other: FieldValue): boolean {
552-
// TODO(mrschmidt): Implement isEquals
553-
return this === other;
554+
return (
555+
other instanceof ArrayRemoveFieldValueImpl &&
556+
deepEqual(this._elements, other._elements)
557+
);
554558
}
555559
}
556560

@@ -568,8 +572,10 @@ export class NumericIncrementFieldValueImpl extends FieldValue {
568572
}
569573

570574
isEqual(other: FieldValue): boolean {
571-
// TODO(mrschmidt): Implement isEquals
572-
return this === other;
575+
return (
576+
other instanceof NumericIncrementFieldValueImpl &&
577+
this._operand === other._operand
578+
);
573579
}
574580
}
575581

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,16 @@ apiDescribe('Count queries', persistence => {
132132
// and will, therefore, never fail in this situation.
133133
// eslint-disable-next-line no-restricted-properties
134134
(USE_EMULATOR ? it.skip : it)(
135-
'getCountFromServer error message is good if missing index',
135+
'getCountFromServer error message contains console link if missing index',
136136
() => {
137137
return withEmptyTestCollection(persistence, async coll => {
138138
const query_ = query(
139139
coll,
140140
where('key1', '==', 42),
141141
where('key2', '<', 42)
142142
);
143+
// TODO(b/316359394) Remove the special logic for non-default databases
144+
// once cl/582465034 is rolled out to production.
143145
if (coll.firestore._databaseId.isDefaultDatabase) {
144146
await expect(
145147
getCountFromServer(query_)
@@ -342,14 +344,16 @@ apiDescribe('Aggregation queries', persistence => {
342344
// and will, therefore, never fail in this situation.
343345
// eslint-disable-next-line no-restricted-properties
344346
(USE_EMULATOR ? it.skip : it)(
345-
'getAggregateFromServer error message is good if missing index',
347+
'getAggregateFromServer error message contains console link good if missing index',
346348
() => {
347349
return withEmptyTestCollection(persistence, async coll => {
348350
const query_ = query(
349351
coll,
350352
where('key1', '==', 42),
351353
where('key2', '<', 42)
352354
);
355+
// TODO(b/316359394) Remove the special logic for non-default databases
356+
// once cl/582465034 is rolled out to production.
353357
if (coll.firestore._databaseId.isDefaultDatabase) {
354358
await expect(
355359
getAggregateFromServer(query_, {

packages/firestore/test/lite/integration.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,16 @@ describe('FieldValue', () => {
883883
expect(deleteField().isEqual(deleteField())).to.be.true;
884884
expect(serverTimestamp().isEqual(serverTimestamp())).to.be.true;
885885
expect(deleteField().isEqual(serverTimestamp())).to.be.false;
886+
expect(arrayUnion().isEqual(arrayUnion())).to.be.true;
887+
expect(arrayUnion('a').isEqual(arrayUnion('a'))).to.be.true;
888+
expect(arrayUnion('a').isEqual(arrayUnion('b'))).to.be.false;
889+
expect(arrayUnion('a', 'b').isEqual(arrayUnion('b', 'a'))).to.be.false;
890+
expect(arrayRemove().isEqual(arrayRemove())).to.be.true;
891+
expect(arrayRemove('a').isEqual(arrayRemove('a'))).to.be.true;
892+
expect(arrayRemove('a').isEqual(arrayRemove('b'))).to.be.false;
893+
expect(arrayRemove('a', 'b').isEqual(arrayRemove('b', 'a'))).to.be.false;
894+
expect(increment(1).isEqual(increment(1))).to.be.true;
895+
expect(increment(1).isEqual(increment(2))).to.be.false;
886896
});
887897

888898
it('support instanceof checks', () => {
@@ -2396,14 +2406,16 @@ describe('Count queries', () => {
23962406
// and will, therefore, never fail in this situation.
23972407
// eslint-disable-next-line no-restricted-properties
23982408
(USE_EMULATOR ? it.skip : it)(
2399-
'getCount error message is good if missing index',
2409+
'getCount error message contains console link if missing index',
24002410
() => {
24012411
return withTestCollection(async coll => {
24022412
const query_ = query(
24032413
coll,
24042414
where('key1', '==', 42),
24052415
where('key2', '<', 42)
24062416
);
2417+
// TODO(b/316359394) Remove the special logic for non-default databases
2418+
// once cl/582465034 is rolled out to production.
24072419
if (coll.firestore._databaseId.isDefaultDatabase) {
24082420
await expect(getCount(query_)).to.be.eventually.rejectedWith(
24092421
/index.*https:\/\/console\.firebase\.google\.com/
@@ -2703,14 +2715,16 @@ describe('Aggregate queries', () => {
27032715
// and will, therefore, never fail in this situation.
27042716
// eslint-disable-next-line no-restricted-properties
27052717
(USE_EMULATOR ? it.skip : it)(
2706-
'getAggregate error message is good if missing index',
2718+
'getAggregate error message contains console link if missing index',
27072719
() => {
27082720
return withTestCollection(async coll => {
27092721
const query_ = query(
27102722
coll,
27112723
where('key1', '==', 42),
27122724
where('key2', '<', 42)
27132725
);
2726+
// TODO(b/316359394) Remove the special logic for non-default databases
2727+
// once cl/582465034 is rolled out to production.
27142728
if (coll.firestore._databaseId.isDefaultDatabase) {
27152729
await expect(
27162730
getAggregate(query_, {

0 commit comments

Comments
 (0)