Skip to content

Commit 0d9adff

Browse files
Improving error message for multiple conflicting fields (#146)
1 parent 7c3bdaa commit 0d9adff

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

conformance/runner.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ const firestore = new Firestore({
4040
const ignoredRe = [
4141
// Node doesn't support field masks for set().
4242
/^set-merge: .*$/,
43+
/set: MergeAll cannot be specified with empty data./, // b/73495873
4344
];
4445

4546
/** If non-empty, list the test cases to run exclusively. */
46-
const exclusiveRe = [
47-
/set: MergeAll cannot be specified with empty data./, // b/73495873
48-
];
47+
const exclusiveRe = [];
4948

5049
const docRef = function(path) {
5150
const relativePath = ResourcePath.fromSlashSeparatedString(path).relativeName;

src/transaction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Transaction {
120120
* @example
121121
* let firstDoc = firestore.doc('col/doc1');
122122
* let secondDoc = firestore.doc('col/doc2');
123-
* let resultDoc = firestore.doc('col/doc2');
123+
* let resultDoc = firestore.doc('col/doc3');
124124
*
125125
* firestore.runTransaction(transaction => {
126126
* return transaction.getAll(firstDoc, secondDoc).then(docs => {

src/write-batch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ function validateUpdateMap(data) {
613613

614614
for (let i = 1; i < fields.length; ++i) {
615615
if (fields[i - 1].isPrefixOf(fields[i])) {
616-
throw new Error(`Field "${fields[i - 1]}" has conflicting definitions.`);
616+
throw new Error(`Field "${fields[i - 1]}" was specified multiple times.`);
617617
}
618618
}
619619

test/document.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,53 +1500,53 @@ describe('update document', function() {
15001500
foo: 'foobar',
15011501
'foo.bar': 'foobar',
15021502
});
1503-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" has conflicting definitions\./);
1503+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
15041504

15051505
assert.throws(() => {
15061506
firestore.doc('collectionId/documentId').update({
15071507
foo: 'foobar',
15081508
'foo.bar.foobar': 'foobar',
15091509
});
1510-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" has conflicting definitions\./);
1510+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
15111511

15121512
assert.throws(() => {
15131513
firestore.doc('collectionId/documentId').update({
15141514
'foo.bar': 'foobar',
15151515
foo: 'foobar',
15161516
});
1517-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" has conflicting definitions\./);
1517+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
15181518

15191519
assert.throws(() => {
15201520
firestore.doc('collectionId/documentId').update({
15211521
'foo.bar': 'foobar',
15221522
'foo.bar.foo': 'foobar',
15231523
});
1524-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo.bar" has conflicting definitions\./);
1524+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo.bar" was specified multiple times\./);
15251525

15261526
assert.throws(() => {
15271527
firestore.doc('collectionId/documentId').update({
15281528
'foo.bar': {foo: 'foobar'},
15291529
'foo.bar.foo': 'foobar',
15301530
});
1531-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo.bar" has conflicting definitions\./);
1531+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo.bar" was specified multiple times\./);
15321532

15331533
assert.throws(() => {
15341534
firestore
15351535
.doc('collectionId/documentId')
15361536
.update('foo.bar', 'foobar', 'foo', 'foobar');
1537-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" has conflicting definitions\./);
1537+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
15381538

15391539
assert.throws(() => {
15401540
firestore
15411541
.doc('collectionId/documentId')
15421542
.update('foo', {foobar: 'foobar'}, 'foo.bar', {foobar: 'foobar'});
1543-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" has conflicting definitions\./);
1543+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
15441544

15451545
assert.throws(() => {
15461546
firestore
15471547
.doc('collectionId/documentId')
15481548
.update('foo', {foobar: 'foobar'}, 'foo.bar', {foobar: 'foobar'});
1549-
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" has conflicting definitions\./);
1549+
}, /Argument "dataOrField" is not a valid UpdateMap. Field "foo" was specified multiple times\./);
15501550
});
15511551

15521552
it('with valid field paths', function() {

0 commit comments

Comments
 (0)