From 577455275de311a2722c246f3a04c34e04335ed7 Mon Sep 17 00:00:00 2001 From: Dhruv Shetty Date: Fri, 13 Jun 2025 18:45:13 +0000 Subject: [PATCH 1/3] returning a list so it matches firestore --- mockfirestore/query.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mockfirestore/query.py b/mockfirestore/query.py index 179ac46..88508f4 100644 --- a/mockfirestore/query.py +++ b/mockfirestore/query.py @@ -57,12 +57,12 @@ def stream(self, transaction=None) -> Iterator[DocumentSnapshot]: if self._limit: doc_snapshots = islice(doc_snapshots, self._limit) - return iter(doc_snapshots) + return iter(list(doc_snapshots)) def get(self) -> Iterator[DocumentSnapshot]: warnings.warn('Query.get is deprecated, please use Query.stream', category=DeprecationWarning) - return self.stream() + return list(self.stream()) def _add_field_filter(self, field: str, op: str, value: Any): compare = self._compare_func(op) From 0f76d69d3199d3b0ff1494a87e48e466394d029c Mon Sep 17 00:00:00 2001 From: Dhruv Shetty Date: Thu, 26 Jun 2025 12:02:19 -0400 Subject: [PATCH 2/3] Update collection.py --- mockfirestore/collection.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mockfirestore/collection.py b/mockfirestore/collection.py index d2af224..ddf4450 100644 --- a/mockfirestore/collection.py +++ b/mockfirestore/collection.py @@ -26,9 +26,8 @@ def document(self, document_id: Optional[str] = None) -> DocumentReference: return DocumentReference(self._data, new_path, parent=self) def get(self) -> Iterable[DocumentSnapshot]: - warnings.warn('Collection.get is deprecated, please use Collection.stream', - category=DeprecationWarning) - return self.stream() + # Stream uses a generator, so we need to convert it to a list + return list(self.stream()) @property def path(self): @@ -127,9 +126,8 @@ def document(self, document_id: Optional[str] = None, path: List[str] = None) -> return ret def get(self) -> Iterable[DocumentSnapshot]: - warnings.warn('Collection.get is deprecated, please use Collection.stream', - category=DeprecationWarning) - return self.stream() + # Stream uses a generator, so we need to convert it to a list for compatibility with firestore library + return list(self.stream()) def stream(self, transaction=None) -> Iterable[DocumentSnapshot]: for path in self._path: From 3b8a509ac0eb23f5f68f68cd8b086a8c241e5075 Mon Sep 17 00:00:00 2001 From: Dhruv Shetty Date: Thu, 26 Jun 2025 12:13:44 -0400 Subject: [PATCH 3/3] update comments --- mockfirestore/collection.py | 4 ++-- mockfirestore/query.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mockfirestore/collection.py b/mockfirestore/collection.py index ddf4450..4e6ae90 100644 --- a/mockfirestore/collection.py +++ b/mockfirestore/collection.py @@ -26,7 +26,7 @@ def document(self, document_id: Optional[str] = None) -> DocumentReference: return DocumentReference(self._data, new_path, parent=self) def get(self) -> Iterable[DocumentSnapshot]: - # Stream uses a generator, so we need to convert it to a list + # Stream uses a generator, so we need to convert it to a list for compatibility for .get() method with firestore library return list(self.stream()) @property @@ -126,7 +126,7 @@ def document(self, document_id: Optional[str] = None, path: List[str] = None) -> return ret def get(self) -> Iterable[DocumentSnapshot]: - # Stream uses a generator, so we need to convert it to a list for compatibility with firestore library + # Stream uses a generator, so we need to convert it to a list for compatibility for .get() method with firestore library return list(self.stream()) def stream(self, transaction=None) -> Iterable[DocumentSnapshot]: diff --git a/mockfirestore/query.py b/mockfirestore/query.py index 88508f4..5698bf0 100644 --- a/mockfirestore/query.py +++ b/mockfirestore/query.py @@ -60,8 +60,7 @@ def stream(self, transaction=None) -> Iterator[DocumentSnapshot]: return iter(list(doc_snapshots)) def get(self) -> Iterator[DocumentSnapshot]: - warnings.warn('Query.get is deprecated, please use Query.stream', - category=DeprecationWarning) + # Stream uses a generator, so we need to convert it to a list for compatibility for .get() method with firestore library return list(self.stream()) def _add_field_filter(self, field: str, op: str, value: Any):