-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: firestoreIssues related to the Firestore API.Issues related to the Firestore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.
Description
The firestore client conflates dot-separated strings with field paths in the update methods. There should be two cases for top-level dict keys passed to update:
- If the key is a string, it is split on dots and cannot contain any of the special characters
~*/[]. There also can't be any empty parts. One reasonable approach is:# validate that there are no special characters in s fp = FieldPath(s.split('.')) - If the key is a
FieldPath, it is treated as-is.
Where FieldPath is something like:
class FieldPath(object):
def __init__(self, *parts):
# Verify that each part is a string, and that no part is the empty string.
def _to_api_repr(self):
# Apply Firestore escaping rules, using backticks and backslashes for parts
# that do not match ^[A-Za-z_][A-Za-z_0-9]*$.
# E.g. FieldPath("a", "~", "`").to_api_repr() => "a.`~`.`\``"
def __eq__(self): # and __ne__ and whatever else is needed to be a dict key.
Since it is now possible to pass a dict where the same effective path occurs twice, that needs to be checked explicitly.
E.g.
{"a": 1, FieldPath("a"): 2}
should be an error.
@schmidt-sebastian Confirm this is accurate.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: firestoreIssues related to the Firestore API.Issues related to the Firestore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.