ioxiocom / firedantic

Database models for Firestore using Pydantic base models.
BSD 3-Clause "New" or "Revised" License
45 stars 13 forks source link

Difference in firestore and firedantic conventions #21

Closed PhilipWee closed 3 years ago

PhilipWee commented 3 years ago

If I use array-contains in a find operation, I get the following error:

File "c:\Users\Philip Wee\Documents\Entreprenuership Collaboro\collaboroo-telegram-bot\env\lib\site-packages\google\cloud\firestore_v1\base_query.py", line 916, in _enum_from_op_string raise ValueError(msg) ValueError: Operator string 'array-contains' is invalid. Valid choices are: !=, <, <=, ==, >, >=, array_contains, array_contains_any, in, not-in.

But if I use array_contains, I instead get the following error:

File "c:\Users\Philip Wee\Documents\Entreprenuership Collaboro\collaboroo-telegram-bot\env\lib\site-packages\firedantic\_sync\model.py", line 88, in _add_filter raise ValueError( ValueError: Unsupported filter type: array_contains. Supported types are: <, <=, ==, >=, !=, >, not-in, array-contains-any, array-contains, in

I'm not sure if my firebase version is wrong, but I think some kind of handler could be put in place to avoid it

joakimnordling commented 3 years ago

@PhilipWee: Thanks you for finding and reporting this bug!

I've now confirmed it. Apparently the array_contains and array_contains_any are spelled with an underscore and the not-in with a dash in the google-cloud-firestore library.