Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions mockfirestore/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 for compatibility for .get() method with firestore library
return list(self.stream())

@property
def path(self):
Expand Down Expand Up @@ -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 for .get() method with firestore library
return list(self.stream())

def stream(self, transaction=None) -> Iterable[DocumentSnapshot]:
for path in self._path:
Expand Down
7 changes: 3 additions & 4 deletions mockfirestore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,11 @@ 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()
# 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):
compare = self._compare_func(op)
Expand Down