-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Labels
🚨This issue needs some love.This issue needs some love.api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: blockedResolving the issue is dependent on other work.Resolving the issue is dependent on other work.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- Cloud Firestore
- Ubuntu 18.04
- Python 3.7
- google-cloud-firestore Version: 0.31.0
Steps to reproduce
- Use ArrayUnion([1,2,3]) on updating nested data in Document reference (see code example bellow)
Code example
from google.cloud import firestore
from google.cloud.firestore_v1beta1 import ArrayUnion
# creating reference
db = firestore.Client()
doc_ref = db.collection(u'test_collection').document(u'test_document')
# creating initial data with nested tree_1
doc_ref.set(
{
u'forest': {
u'tree_1': u'oak'
}
}
)
# getting document after initial data
print('Here is initial data with 1 nested tree', doc_ref.get().to_dict())
# adding tree_2 to nested data (tree_1 remains in nested data)
doc_ref.set(
{
u'forest': {
u'tree_2': u'pine'
}
},
merge=True
)
print('Here is 2 trees in nested data after using set(merge=true)', doc_ref.get().to_dict())
# this code removes other nested data in document
# including tree_1 and tree_2, even if merge=true is used
doc_ref.set(
{
u'forest': {
u'tree_3': ArrayUnion([u'spruce'])
}
},
merge=True
)
print('after using ArrayUnion, all previous nested data is removed', doc_ref.get().to_dict())Stack trace
Here is initial data with 1 nested tree {'forest': {'tree_1': 'oak'}}
Here is 1 initial tree and 1 additional tree after set(merge=true) {'forest': {'tree_1': 'oak', 'tree_2': 'pine'}}
after using set(merge=true) with ArrayUnion all nested data is removed {'forest': {'tree_3': ['spruce']}}
Many Thanks!
A-Iskakov and saltas888
Metadata
Metadata
Assignees
Labels
🚨This issue needs some love.This issue needs some love.api: firestoreIssues related to the googleapis/python-firestore API.Issues related to the googleapis/python-firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.status: blockedResolving the issue is dependent on other work.Resolving the issue is dependent on other work.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.