Skip to content

Firestore - Inconsistent behavior in key addressing #288

@Pirayya

Description

@Pirayya

OS Type: Its Java - version 11
Firestore Java SDK version (1.33.0, but I can see that the problem still exists in the code on master)

Using field keys with dots (.), i.e. my.key: "My value" is allowed, albeit a bit frowned upon, has inconsistent behavior when creating compared to deleting. It is perfectly fine to create a key with dots but cannot be deleted (unless it exists on the top level of the document).

{
   "my.key": true
}

can be removed, but:

{
   "my": {
      "specialized.key": true
   }
}

cannot.

That's not all! Using the JavaScript SDK for Firestore, deleting is not a problem.

It is always debatable whether or not to use dots in keys, but I think the inconsistency is something that has to be fixed.

Steps to reproduce

  1. Create a document like the one above (with specialized.key)
  2. Run one of the code blocks below
var updates = Map.of("my.specialized.key", FieldValue.delete());
firestore.collection("myCollection").document("myDocument").update(updates)

or

var path = new FieldPath("my", "specialized.key");
firestore.collection("myCollection").document("myDocument").update(path, FieldValue.delete()) // <-- Very similar to JavaScript SDK

The first code block will succeed without any change, but the second will result in a failed Precondition.

Code example

See steps to reproduce

Stack trace

Will fail right here:

options.allowDelete(path), "FieldValue.delete() is not supported at field '%s'.", path);

If you don't have time to fix this issue(? don't know if you regard this as an issue), I can definitely contribute!

Tell me if anything is unclear!

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: firestoreIssues related to the googleapis/java-firestore API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions