- edited description
Cannot use chained index_property setter
The example below demonstrates the problem. An index_property
that references another index_property
has a broken setter.
The problem is that flag_modified
is called on the first index_property
. Tested on SQLAlchemy 1.1.5, it looks like this bug has always been there since the indexable extension was added.
from sqlalchemy import Column, Integer
from sqlalchemy.dialects.postgresql import JSON
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.indexable import index_property
Base = declarative_base()
class Thing(Base):
__tablename__ = 'thing'
id = Column(Integer, primary_key=True)
data = Column(JSON)
field = index_property('data', 'field', default=dict())
subfield = index_property('field', 'subfield')
# Can set field ok
thing1 = Thing(field=dict())
print(thing1.data)
# Trying to set subfield doesn't work
thing2 = Thing(subfield='a')
print(thing2.data)
Comments (7)
-
reporter -
repo owner hi @razerm -
I'm going to ping the person that contributed this to look into it. I like the indexable feature very much but when it was first proposed I was very concerned about the maintenance burden it gives me, so hopefully the contributor can continue to maintain it.
-
repo owner @youknowone is it possible to to look into this?
-
repo owner - changed component to ext
- changed milestone to 1.1.x
-
assigned issue to
-
Ok, I will look into it.
-
I created a patch and uploaded it to gerrit, but I need your advice for an implementation detail.
-
repo owner - changed status to resolved
Fix nested index_property setter when there is no container value
Fixed bug in new :mod:
sqlalchemy.ext.indexable
extension where setting of a property that itself refers to another property would fail.Fixes:
#3901Change-Id: I203a66117e2399afee11a34f43f0e93adfc6d571→ <<cset f411cac35001>>
- Log in to comment