-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement MergeOption
as an option
#4851
Implement MergeOption
as an option
#4851
Conversation
77795e1
to
2efc83f
Compare
2efc83f
to
16c9588
Compare
16c9588
to
c5e2ed4
Compare
c5e2ed4
to
03dc67f
Compare
MergeOption
as an option
08f0ee5
to
e0d9b28
Compare
@@ -768,6 +763,22 @@ def get_doc_id(document_pb, expected_prefix): | |||
return document_id | |||
|
|||
|
|||
def get_field_paths(update_data): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -880,15 +891,16 @@ def pbs_for_set(document_path, document_data, option): | |||
or two ``Write`` protobuf instances for ``set()``. | |||
""" | |||
transform_paths, actual_data = remove_server_timestamp(document_data) | |||
|
|||
update_pb = write_pb2.Write( | |||
update=document_pb2.Document( | |||
name=document_path, | |||
fields=encode_dict(actual_data), | |||
), | |||
) | |||
if option is not None: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
|
||
DEFAULT_DATABASE = '(default)' | ||
"""str: The default database used in a :class:`~.firestore.client.Client`.""" | ||
_BAD_OPTION_ERR = ( | ||
'Exactly one of ``create_if_missing``, ``last_update_time`` ' | ||
'and ``exists`` must be provided.') | ||
'Exactly one of ``last_update_time`` or ``exists`` must be provided.') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
elif not self._create_if_missing: | ||
current_doc = types.Precondition(exists=True) | ||
write_pb.current_document.CopyFrom(current_doc) | ||
mask = common_pb2.DocumentMask(field_paths=sorted(field_paths)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
7eec589
to
1af5b12
Compare
fa1e5d0
to
53159e9
Compare
2ea0832
to
93f0441
Compare
93f0441
to
138111b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty close from a functional perspective. Some comments (mostly small nits) remaining.
Can you send this over to someone that understands Python after you resolved these last comments? Thanks!
for sub_path in sub_transform_paths: | ||
field_path = FieldPath.from_string(field_name) | ||
field_path.parts = field_path.parts + sub_path.parts | ||
transform_paths.extend([field_path]) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
if split_on_dots: | ||
transform_paths.append(FieldPath(*field_name.split("."))) | ||
else: | ||
transform_paths.append(FieldPath.from_string(field_name)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
else: | ||
return field_paths, document_data | ||
field_paths.append(FieldPath(field_name)) | ||
if not transform_paths: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -39,8 +39,8 @@ | |||
DEFAULT_DATABASE = '(default)' | |||
"""str: The default database used in a :class:`~.firestore.client.Client`.""" | |||
_BAD_OPTION_ERR = ( | |||
'Exactly one of ``create_if_missing``, ``last_update_time`` ' | |||
'and ``exists`` must be provided.') | |||
'Exactly one of ``last_update_time``, ``exists`` ' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
firestore/tests/system.py
Outdated
|
||
# 1. Use ``set()`` to create the document (using an option). | ||
# 1. Use ``create()`` to create the document (using an option). |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
data2 = {'1a.ab': '4d', '6f.7g': '9h'} | ||
option2 = client.write_option(create_if_missing=True) | ||
option2 = client.write_option(exists=True) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
firestore/tests/system.py
Outdated
snapshot = document.get() | ||
assert not snapshot.exists | ||
|
||
# 1. Use ``set()`` to create the document (using an option). |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
self.run_write_test(test_proto, desc) | ||
except (AssertionError, Exception) as error: | ||
count += 1 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
elif kind == "set": | ||
tp = test_proto.set | ||
client, doc = self.setup(firestore_api, tp) | ||
data = convert_data(json.loads(tp.json_data)) | ||
# TODO: call doc.set. | ||
if tp.HasField("option"): | ||
option = True |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
10d612b
to
b166f06
Compare
Hey, this finally made it to Pypi in a release, and unfortunately broke some things for me. This PR removes
It looks like the migration here is (?):
Given the arg ordering, an ugly backwards compatibility patch could be:
|
@mikedh The Firestore API team explicitly asked us to remove @schmidt-sebastian Can you comment here? |
That's the correct API change, just looks like it took a bit longer for it to land in Python than the other SDKs and we didn't time the doc updates with the release. I'll get the docs updated. |
Fixing here: |
Thanks! The API change seems like an improvement. |
Should close #4111
The first and second commits is #4654.