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
frombloopimportBaseModel, DateTime, String, Column, EngineclassMyModel(BaseModel):
id=Column(String, hash_key=True)
date=Column(DateTime, range_key=True)
e=Engine()
e.bind(MyModel, skip_table_setup=True)
condition_hk=MyModel.id=="foo"condition_rk=MyModel.date.begins_with("2021-11")
condition=condition_hk&condition_rk# this line fails:# AttributeError: 'str' object has no attribute 'in_timezone'q=e.query(MyModel, condition)
This is because DateTime assumes only a datetime.datetime instance will be passed through dynamo_dump but for the begins_with condition we'll often pass a string prefix of the serialized datetime object. For example, filtering on a datetime range key to a single month.
One possible solution is to pass an additional field(s) through the context. Some rough first drafts:
Today, only "engine" is required. The additional fields would vary based on what high-level operation is happening, and there's some unpacking we should do for ease of use (eg. point at each item in the AndCondition instead of the AndCondition itself).
To find all call sites, look for Type._dump or Type._load. Specifically look for calls to:
This is because
DateTime
assumes only adatetime.datetime
instance will be passed throughdynamo_dump
but for thebegins_with
condition we'll often pass a string prefix of the serialized datetime object. For example, filtering on a datetime range key to a single month.One possible solution is to pass an additional field(s) through the
context
. Some rough first drafts:Today, only
"engine"
is required. The additional fields would vary based on what high-level operation is happening, and there's some unpacking we should do for ease of use (eg. point at each item in the AndCondition instead of the AndCondition itself).To find all call sites, look for
Type._dump
orType._load
. Specifically look for calls to:ReferenceTracker._value_ref
which is used directly byconditions.render
which is used in multiple places (Engine.*
,PreparedTransaction._prepare_request
)models.unpack_from_dynamodb
which is used directly by Engine, Search, Stream, Transaction.The text was updated successfully, but these errors were encountered: