DynamoDB: BETWEEN no longer excludes an attribute value of 0 - #10193
Open
aryansk wants to merge 1 commit into
Open
DynamoDB: BETWEEN no longer excludes an attribute value of 0#10193aryansk wants to merge 1 commit into
aryansk wants to merge 1 commit into
Conversation
FuncBetween.expr() tested the attribute with bare truthiness, so a
Decimal('0') value failed the condition and was excluded even when it
fell inside the range. Apply the same zero-safe check start/end already
use. Regression test fails on main; condition-expression suite passes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10186.
What
FuncBetween.expr()tested the compared attribute with bare Python truthiness (and attr). SinceDecimal("0")is falsy, an item whose attribute value is exactly0failed aBETWEENrange even when0was inside it — e.g.price BETWEEN 0 AND 100excludedprice = 0while includingprice = 5.Why
The
startandendoperands already use a zero-safe check (start is not None and (isinstance(start, Decimal) or start)) for exactly this reason; the attribute operand was missed, so0behaves differently from any other number.How
Give the attribute the same zero-safe check in all three branches:
Tests
New
test_between_condition_includes_zeroscans withprice BETWEEN :lo AND :hiand assertsprice = 0is included (0..100returns both items;-10..0returns the zero item). Fails onmain({'five'} == {'five', 'zero'}), passes with the fix. Fulltest_dynamodb_condition_expressions.pysuite passes; ruff findings oncomparisons.pyare pre-existing and untouched.