DynamoDB BETWEEN incorrectly excludes attribute value 0
Author: Sohel2309Created Aug 14, 2026Updated Aug 15, 2026
Bug
DynamoDB BETWEEN filtering incorrectly excludes items whose attribute
value is exactly 0, even when 0 is within the specified range.
Reproduction
An item with:
price = 0is incorrectly excluded from:
price BETWEEN 0 AND 100while an item with price = 5 is included.
Root cause
FuncBetween.expr() checks the tested attribute using bare Python
truthiness (and attr). Since Decimal("0") is falsy, an attribute
whose value is zero incorrectly fails the condition.
The start and end operands already use zero-safe checks for this
exact reason, but attr does not.
Expected behavior
An attribute value of 0 should be included when it falls within the
specified BETWEEN range.
Source: getmoto/moto