Skip to content

Support tuple when encoding to Firestore value #20

@hongquan

Description

@hongquan

Thanks for stopping by to let us know something could be better!

Is your feature request related to a problem? Please describe.
When I save data to Firestore, it reject when the data contains tuple.

  File "/env/local/lib/python3.7/site-packages/google/cloud/firestore_v1/_helpers.py", line 200, in encode_value
    "Cannot convert to a Firestore Value", value, "Invalid type", type(value)
TypeError: ('Cannot convert to a Firestore Value', (1, 12), 'Invalid type', <class 'tuple'>)

Describe the solution you'd like

It should accept tuple. This is pragmatic because when I decide to submit data to Firestore, I no longer need to modify the content, so I leave it in a immutable type like tuple.

Describe alternatives you've considered
Change the encode_value() function:

    if isinstance(value, list):
        value_list = [encode_value(element) for element in value]

to this

    if isinstance(value, (list, tuple, set, frozenset)):
        value_list = tuple(encode_value(element) for element in value)

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the googleapis/python-firestore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions