Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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: 0 additions & 1 deletion firestore/google/cloud/firestore_v1beta1/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ class CreateIfMissingOption(WriteOption):
create_if_missing (bool): Indicates if the document should be created
if it doesn't already exist.
"""

def __init__(self, create_if_missing):
self._create_if_missing = create_if_missing

Expand Down
17 changes: 17 additions & 0 deletions firestore/tests/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,23 @@ def test_document_set(client, cleanup):
assert exc_to_code(exc_info.value.cause) == StatusCode.FAILED_PRECONDITION


def test_document_integer_field(client, cleanup):
document_id = 'for-set' + unique_resource_id('-')
document = client.document('i-did-it', document_id)
# Add to clean-up before API request (in case ``set()`` fails).
cleanup(document)

data1 = {'1a': 'SF'}
option1 = client.write_option(exists=False)
write_result1 = document.set(data1, option=option1)

data2 = {'1a': 'LA'}
option2 = client.write_option(merge=True)
write_result2 = document.set(data2, option=option2)
snapshot = document.get()
assert snapshot.to_dict() == {'1a': 'LA'}


def test_update_document(client, cleanup):
document_id = 'for-update' + unique_resource_id('-')
document = client.document('made', document_id)
Expand Down
15 changes: 15 additions & 0 deletions firestore/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,3 +780,18 @@ def _doc_get_info(ref_string, values):
)

return document_pb, read_time


class TestMergeOption(unittest.TestCase):

@staticmethod
def _get_target_class():
from google.cloud.firestore_v1beta1 import client

return client.MergeOption()

def test__convert_simple_field_paths_with_leading_digits(self):
klass = self._get_target_class()
field_paths = ["0abc", "abc", "321"]
convert = klass._convert_simple_fields_with_leading_digits(field_paths)
self.assertListEqual(convert, ["`0abc`", "abc", "`321`"])