Skip to content

Commit 35511b2

Browse files
committed
renamed DocumentMatches
1 parent ffb6dbb commit 35511b2

4 files changed

Lines changed: 13 additions & 62 deletions

File tree

packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline_expressions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,20 +2676,24 @@ def __init__(self):
26762676
super().__init__("rand", [], use_infix_repr=False)
26772677

26782678

2679-
def document_matches(query: Expression | str) -> BooleanExpression:
2679+
class DocumentMatches(BooleanExpression):
26802680
"""Creates a boolean expression for a document match query.
26812681
26822682
Example:
26832683
>>> # Find documents matching the query string
2684-
>>> document_matches("search query")
2684+
>>> DocumentMatches("search query")
26852685
26862686
Args:
26872687
query: The search query string or expression.
26882688
26892689
Returns:
26902690
A new `BooleanExpression` representing the document match.
26912691
"""
2692-
return BooleanExpression(
2693-
"document_matches", [Expression._cast_to_expr_or_convert_to_constant(query)]
2694-
)
2692+
2693+
def __init__(self, query: Expression | str):
2694+
super().__init__(
2695+
"document_matches",
2696+
[Expression._cast_to_expr_or_convert_to_constant(query)],
2697+
use_infix_repr=False,
2698+
)
26952699

packages/google-cloud-firestore/google/cloud/firestore_v1/pipeline_stages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def __init__(
152152
language_code (Optional[str]): The BCP-47 language code of text in the search query, such as "en-US" or "sr-Latn".
153153
"""
154154
if isinstance(query, str):
155-
from google.cloud.firestore_v1.pipeline_expressions import document_matches
156-
self.query = document_matches(query)
155+
from google.cloud.firestore_v1.pipeline_expressions import DocumentMatches
156+
self.query = DocumentMatches(query)
157157
else:
158158
self.query = query
159159
self.limit = limit

packages/google-cloud-firestore/tests/unit/v1/test_pipeline_expressions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,10 @@ def test_geo_distance(self):
815815

816816
def test_document_matches(self):
817817
arg1 = self._make_arg("Query")
818-
instance = expr.document_matches(arg1)
818+
instance = expr.DocumentMatches(arg1)
819819
assert instance.name == "document_matches"
820820
assert instance.params == [arg1]
821-
assert repr(instance) == "document_matches(Query)"
821+
assert repr(instance) == "DocumentMatches(Query)"
822822

823823
def test_greater_than_or_equal(self):
824824
arg1 = self._make_arg("Left")

packages/google-cloud-firestore/tests/unit/v1/test_pipeline_search.py

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

0 commit comments

Comments
 (0)