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

Added 'array_contains' to the _COMPARISON_OPERATORS dict, to enable using array_contains in firestore queries. #6481

Merged
merged 2 commits into from
Nov 13, 2018

Conversation

RohanTalip
Copy link
Contributor

This appears to fix #6479.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 12, 2018
@RohanTalip
Copy link
Contributor Author

Prior to this change, I was getting this error:

...
  File "/project/appengine/main/venv3/lib/python3.6/site-packages/google/cloud/firestore_v1beta1/collection.py", line 215, in where
    return query.where(field_path, op_string, value)
  File "/project/appengine/main/venv3/lib/python3.6/site-packages/google/cloud/firestore_v1beta1/query.py", line 226, in where
    op=_enum_from_op_string(op_string),
  File "/project/appengine/main/venv3/lib/python3.6/site-packages/google/cloud/firestore_v1beta1/query.py", line 627, in _enum_from_op_string
    raise ValueError(msg)
ValueError: Operator string 'array_contains' is invalid. Valid choices are: <, <=, ==, >, >=.

With the change in this pull request patched locally, my query now appears to work.

@tseaver
Copy link
Contributor

tseaver commented Nov 13, 2018

@RohanTalip Thanks for the patch! Can you please exercise the new operator in the unit test for '_enum_from_op_string'.

@tseaver tseaver added the api: firestore Issues related to the Firestore API. label Nov 13, 2018
@RohanTalip
Copy link
Contributor Author

RohanTalip commented Nov 13, 2018

@tseaver, done.

I don't see the circleci tests actually running any Python / pytest tests, but they passed locally:

$ cd firestore
$ virtualenv -p /usr/bin/python3 venv3
$ . venv3/bin/activate
$ pip install pytest
$ pip install mock
$ pip install -e .
$ pip install -e ../core/.
$ pytest
============================================================================== test session starts ===============================================================================
platform linux -- Python 3.6.5, pytest-3.10.1, py-1.7.0, pluggy-0.8.0
rootdir: /gitwork/googleapis/google-cloud-python/firestore, inifile:
collected 427 items                                                                                                                                                              

tests/unit/test__helpers.py .....................................................................................................................................          [ 31%]
tests/unit/test_batch.py ........                                                                                                                                          [ 33%]
tests/unit/test_client.py ...................................                                                                                                              [ 41%]
tests/unit/test_collection.py ..........................                                                                                                                   [ 47%]
tests/unit/test_cross_language.py .                                                                                                                                        [ 47%]
tests/unit/test_document.py ..............................................                                                                                                 [ 58%]
tests/unit/test_order.py ....                                                                                                                                              [ 59%]
tests/unit/test_query.py .......................................................                                                                                           [ 72%]
tests/unit/test_transaction.py ........................................                                                                                                    [ 81%]
tests/unit/test_watch.py .....................................................                                                                                             [ 93%]
tests/unit/gapic/v1beta1/test_firestore_client_v1beta1.py ..........................                                                                                       [100%]


================================================================================ warnings summary ================================================================================
... (lots of warnings)
==================================================================== 427 passed, 57 warnings in 9.94 seconds =====================================================================

@tseaver tseaver merged commit ce2a5fe into googleapis:master Nov 13, 2018
tseaver added a commit that referenced this pull request Nov 15, 2018
tseaver added a commit that referenced this pull request Nov 15, 2018
* Firestore: pick up fixes to GAPIC generator.

Closes #6497.

Includes changes to generated tests.

Includes fixes from these PRs:

- googleapis/gapic-generator#2407
- googleapis/gapic-generator#2396

* Fix overlong lines introduced in PR #6481.
erikwebb pushed a commit to erikwebb/google-cloud-python that referenced this pull request Dec 3, 2018
* Firestore: pick up fixes to GAPIC generator.

Closes googleapis#6497.

Includes changes to generated tests.

Includes fixes from these PRs:

- googleapis/gapic-generator#2407
- googleapis/gapic-generator#2396

* Fix overlong lines introduced in PR googleapis#6481.
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 Firestore API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please support array_contains in queries
3 participants