-
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
FireStore: Saving items that have both empty object values and SERVER_TIMESTAMP results in missing attributes. #5944
Comments
I can verify that the |
@lukesneeringer added an explicit skip of empty dicts in @jba Can you confirm one way or another whether skipping empty dict values is correct? |
You can implement this in a couple different ways, but in order to get the conformance tests to pass, you need to send the absolute minimum requests that produces the desired outcome:
This cases are covered well by the conformance tests, and I am a little surprised that this is broken. Let me know if I am not understanding this correctly. |
@schmidt-sebastian The reported case is a combination of the two. The code in Python which generates the server transform ends up munging the data (to comb out the server timestamp fields) and ends up dropping empty maps. |
I think the intent of the code in place is to avoid sending an empty map if the original map contained only server transforms: it overlooks the case that the map was originally empty. |
@jadekler to add this case to the conformance tests. |
PR #6050 implements a fix based on the understanding I noted above. |
For context see: * googleapis/google-cloud-python#5944 * https://github.com/googleapis/google-cloud-common/pull/264 In PHP we can differentiate between Firestore maps and arrays based on whether the PHP array is associative or not. That difference gets considerably trickier when considering empty arrays. To create an empty map in PHP's Firestore client, you must explicitly provide `(object) []`.
For context see: * googleapis/google-cloud-python#5944 * https://github.com/googleapis/google-cloud-common/pull/264 In PHP we can differentiate between Firestore maps and arrays based on whether the PHP array is associative or not. That difference gets considerably trickier when considering empty arrays. To create an empty map in PHP's Firestore client, you must explicitly provide `(object) []`.
When saving data to firestore with an attribute that is an empty
{}
:if the date fields are
firestore.SERVER_TIMESTAMP
then the field with an empty{}
is not persisted to the db but if the date fields areDatetime
instances then the empty object fields are persisted.OS type and version
e 6.4.0) ) Add support for namespaces #1 SMP Wed Jun 6 16:55:56 UTC 2018
Python version and virtual environment information
python --version
Python 3.6.6
google-cloud-python versions
google-api-core==1.3.0
google-auth==1.5.1
google-cloud-core==0.28.1
google-cloud-firestore==0.29.0
google-cloud-storage==1.11.0
google-resumable-media==0.3.1
Stacktrace if available
NA
Steps to reproduce
resources
attribute is not present.save with
date_created
anddate_modified
=datetime.datetime.utcnow()
andresources
attributes is set with an empty object value.The text was updated successfully, but these errors were encountered: