Skip to content

FireStore: Saving items that have both empty object values and SERVER_TIMESTAMP results in missing attributes. #5944

@hishnash

Description

@hishnash

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 are Datetime instances then the empty object fields are persisted.

OS type and version

  1. MacOS 10.13.6 (17G2307)
  2. DOCKER container: Linux version 4.9.93-linuxkit-aufs (root@856d34d1168e) (gcc version 6.4.0 (Alpin
    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

  1. save to the db:
data = {
     'date_created': firestore.SERVER_TIMESTAMP,
     'date_modified': firestore.SERVER_TIMESTAMP,
     'resources': {}
}

transaction.set(
    reference,
    data,
    option=db.write_option(exists=False),
)
  1. look in firestore and notice resources attribute is not present.

save with date_created and date_modified = datetime.datetime.utcnow() and resources attributes is set with an empty object value.

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the Firestore API.priority: p2Moderately-important priority. Fix may not be included in next release.status: investigatingThe issue is under investigation, which is determined to be non-trivial.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions