Skip to content

Commit fd45274

Browse files
Revert "Support the 'field' argument in collection 'where' query calls (#1)"
This reverts commit f91d895.
1 parent f91d895 commit fd45274

File tree

9 files changed

+17
-231
lines changed

9 files changed

+17
-231
lines changed

.github/workflows/pr_agent.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
name: Test
2-
on: [ push, pull_request ]
2+
on: [push, pull_request]
33

44
jobs:
55
test:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
9+
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10' ]
1010

1111
steps:
12-
- name: Check out repository
13-
uses: actions/checkout@v4
14-
12+
- uses: actions/checkout@v2
1513
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v4
14+
uses: actions/setup-python@v2
1715
with:
1816
python-version: ${{ matrix.python-version }}
1917
- name: Install dependencies

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,3 @@ venv.bak/
106106
.mypy_cache/
107107

108108
.idea/
109-
.qodo

agent-coding-standards.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

mockfirestore/collection.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from mockfirestore import AlreadyExists
55
from mockfirestore._helpers import generate_random_string, Store, get_by_path, set_by_path, Timestamp
6-
from mockfirestore.query import Query, FieldFilter
6+
from mockfirestore.query import Query
77
from mockfirestore.document import DocumentReference, DocumentSnapshot
88

99

@@ -41,10 +41,9 @@ def add(self, document_data: Dict, document_id: str = None) \
4141
timestamp = Timestamp.from_now()
4242
return timestamp, doc_ref
4343

44-
def where(self, field: str = None, op: str = None, value: Any = None, *, filter: FieldFilter = None) -> Query:
45-
if filter is not None:
46-
return Query(self, field_filters=[(filter.field, filter.op, filter.value)])
47-
return Query(self, field_filters=[(field, op, value)])
44+
def where(self, field: str, op: str, value: Any) -> Query:
45+
query = Query(self, field_filters=[(field, op, value)])
46+
return query
4847

4948
def order_by(self, key: str, direction: Optional[str] = None) -> Query:
5049
query = Query(self, orders=[(key, direction)])
@@ -83,4 +82,4 @@ def list_documents(self, page_size: Optional[int] = None) -> Sequence[DocumentRe
8382
def stream(self, transaction=None) -> Iterable[DocumentSnapshot]:
8483
for key in sorted(get_by_path(self._data, self._path)):
8584
doc_snapshot = self.document(key).get()
86-
yield doc_snapshot
85+
yield doc_snapshot

mockfirestore/query.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import warnings
22
from itertools import islice, tee
33
from typing import Iterator, Any, Optional, List, Callable, Union
4-
from dataclasses import dataclass
54

65
from mockfirestore.document import DocumentSnapshot
76
from mockfirestore._helpers import T
87

9-
@dataclass
10-
class FieldFilter:
11-
field: str
12-
op: str
13-
value: Any
14-
15-
def __init__(self, field: str, op: str, value: Any):
16-
self.field = field
17-
self.op = op
18-
self.value = value
19-
208

219
class Query:
2210
def __init__(self, parent: 'CollectionReference', projection=None,
@@ -73,11 +61,8 @@ def _add_field_filter(self, field: str, op: str, value: Any):
7361
compare = self._compare_func(op)
7462
self._field_filters.append((field, compare, value))
7563

76-
def where(self, field: str = None, op: str = None, value: Any = None, *, filter: FieldFilter = None) -> 'Query':
77-
if filter is not None:
78-
self._add_field_filter(filter.field, filter.op, filter.value)
79-
else:
80-
self._add_field_filter(field, op, value)
64+
def where(self, field: str, op: str, value: Any) -> 'Query':
65+
self._add_field_filter(field, op, value)
8166
return self
8267

8368
def order_by(self, key: str, direction: Optional[str] = 'ASCENDING') -> 'Query':
@@ -151,4 +136,4 @@ def _compare_func(self, op: str) -> Callable[[T, T], bool]:
151136
elif op == 'array_contains':
152137
return lambda x, y: y in x
153138
elif op == 'array_contains_any':
154-
return lambda x, y: any([val in y for val in x])
139+
return lambda x, y: any([val in y for val in x])

requirements-dev-minimal.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-cloud-firestore
1+
google-cloud-firestore

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="mock-firestore",
8-
version="0.12.0",
8+
version="0.11.0",
99
author="Matt Dowds",
1010
description="In-memory implementation of Google Cloud Firestore for use in tests",
1111
long_description=long_description,
@@ -14,9 +14,11 @@
1414
packages=setuptools.find_packages(),
1515
test_suite='',
1616
classifiers=[
17+
'Programming Language :: Python :: 3.6',
18+
'Programming Language :: Python :: 3.7',
19+
'Programming Language :: Python :: 3.8',
1720
'Programming Language :: Python :: 3.9',
1821
'Programming Language :: Python :: 3.10',
19-
'Programming Language :: Python :: 3.11',
2022
"License :: OSI Approved :: MIT License",
2123
],
2224
)

tests/test_where_field.py

Lines changed: 0 additions & 138 deletions
This file was deleted.

0 commit comments

Comments
 (0)