Skip to content

Commit ffb6dbb

Browse files
committed
made between into a wrapper expression
1 parent 750452c commit ffb6dbb

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -626,13 +626,9 @@ def between(
626626
Returns:
627627
A new `BooleanExpression` representing the between comparison.
628628
"""
629-
return BooleanExpression(
630-
"between",
631-
[
632-
self,
633-
self._cast_to_expr_or_convert_to_constant(lower),
634-
self._cast_to_expr_or_convert_to_constant(upper),
635-
],
629+
return And(
630+
self.greater_than_or_equal(lower),
631+
self.less_than_or_equal(upper),
636632
)
637633

638634
@expose_as_static

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,11 @@ def test_between(self):
795795
arg2 = self._make_arg("Lower")
796796
arg3 = self._make_arg("Upper")
797797
instance = Expression.between(arg1, arg2, arg3)
798-
assert instance.name == "between"
799-
assert instance.params == [arg1, arg2, arg3]
800-
assert repr(instance) == "Left.between(Lower, Upper)"
798+
assert instance.name == "and"
799+
assert len(instance.params) == 2
800+
assert instance.params[0].name == "greater_than_or_equal"
801+
assert instance.params[1].name == "less_than_or_equal"
802+
assert repr(instance) == "And(Left.greater_than_or_equal(Lower), Left.less_than_or_equal(Upper))"
801803
infix_instance = arg1.between(arg2, arg3)
802804
assert infix_instance == instance
803805

0 commit comments

Comments
 (0)