You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
contains() on lists and sets of datetimes, UUIDs or documents raises ValidationError #112
Priority: low.contains() on a model field that holds a list or set of values with a codec (list[datetime], list[date], set[UUID], list[timedelta], a list of plain Enum members or of documents) puts the Python value into the expression unencoded, so every request with it fails before any I/O:
classBird(dynamoxy.Model, table="birds"):
bird_id: Attr[str] =dynamoxy.partition_key()
seen: Attr[list[datetime]] =dynamoxy.field(default_factory=list)
awaitbirds.scan().filter(Bird.seen.contains(moment)).count()
# ValidationError: :v0: cannot store a value of type datetime in DynamoDB; use str, int, ...
Lists and sets of str, numbers and bytes work only because their values need no encoding, and Bird.seen[0] == moment encodes the value as stored.
Where:python/dynamoxy/attributes.py, FieldPath.contains. It builds a Path whose encoder is the element codec, and Path.contains then takes that codec's element() again, which is None for these types, so the value is neither validated nor encoded.
Fix: validate and encode the value with self.spec.codec.element() directly, as FieldPath._value does for comparisons, and test contains() on lists and sets of datetimes, UUIDs and documents on both backends.
Activity
fix(expressions): contains() encodes members of lists and sets as the…