From 840dd32c3307b73d58b17ca6af631437b48014d3 Mon Sep 17 00:00:00 2001 From: Lukas Karlsson Date: Thu, 20 Feb 2025 11:10:59 -0500 Subject: [PATCH] Fixed UserWarning about preferring 'filter' keyword for query. --- CHANGELOG.md | 6 ++++++ firedantic/_async/model.py | 3 ++- firedantic/_sync/model.py | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 374b38b..3b571a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +## Fixed + +- Switched Firestore `query.where()` to use the 'filter' keyword argument instead of + positional arguments. This eliminates a UserWarning that was introduced in + `google-cloud-firestore` 2.11.0. + ## [0.8.1] - 2024-12-09 ### Changed diff --git a/firedantic/_async/model.py b/firedantic/_async/model.py index edf0e94..5141a6a 100644 --- a/firedantic/_async/model.py +++ b/firedantic/_async/model.py @@ -188,7 +188,8 @@ def _add_filter( query: AsyncQuery = query.where(filter=_filter) # type: ignore return query else: - query: AsyncQuery = query.where(field, "==", value) # type: ignore + _filter = FieldFilter(field, "==", value) + query: AsyncQuery = query.where(filter=_filter) # type: ignore return query @classmethod diff --git a/firedantic/_sync/model.py b/firedantic/_sync/model.py index d9e0afb..2c4d5f4 100644 --- a/firedantic/_sync/model.py +++ b/firedantic/_sync/model.py @@ -188,7 +188,8 @@ def _add_filter( query: BaseQuery = query.where(filter=_filter) # type: ignore return query else: - query: BaseQuery = query.where(field, "==", value) # type: ignore + _filter = FieldFilter(field, "==", value) + query: BaseQuery = query.where(filter=_filter) # type: ignore return query @classmethod