Skip to content
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

Support tuple when encoding to Firestore value #20

Closed
hongquan opened this issue Feb 20, 2020 · 0 comments · Fixed by #21
Closed

Support tuple when encoding to Firestore value #20

hongquan opened this issue Feb 20, 2020 · 0 comments · Fixed by #21
Assignees
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@hongquan
Copy link
Contributor

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.

@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/python-firestore API. label Feb 20, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Feb 20, 2020
@BenWhitehead BenWhitehead added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/python-firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants