Skip to content

Throw proper error for FieldValue transforms in arrays #3183

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

Merged
merged 3 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions packages/firestore/src/api/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export class FirebaseCredentialsProvider implements CredentialsProvider {
// outstanding so the response is potentially for a previous user (which
// user, we can't be sure).
if (this.tokenCounter !== initialTokenCounter) {
this.forceRefresh = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change related to the fix at hand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this is meant for a different PR. Removed.

throw new FirestoreError(
Code.ABORTED,
'getToken aborted due to token change.'
Expand Down
2 changes: 1 addition & 1 deletion packages/firestore/src/api/user_data_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ function parseSentinelFieldValue(
`${value._methodName}() can only be used with update() and set()`
);
}
if (context.path === null) {
if (!context.path) {
throw context.createError(
`${value._methodName}() is not currently supported inside arrays`
);
Expand Down
12 changes: 12 additions & 0 deletions packages/firestore/test/integration/api/validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,18 @@ apiDescribe('Validation:', (persistence: boolean) => {
}
);

validationIt(
persistence,
'must not contain field value transforms in arrays',
db => {
return expectWriteToFail(
db,
{ 'array': [FieldValue.serverTimestamp()] },
'FieldValue.serverTimestamp() is not currently supported inside arrays'
);
}
);

validationIt(
persistence,
'must not contain directly nested arrays.',
Expand Down