- changed status to resolved
AttributeError: 'Child' object has no attribute 'parent_id'
Issue #3117
resolved
I get an error when executing an update ONLY after eager loading an association object. I can reproduce this on 0.9.4 and 0.9.6.
In order to reproduce it you need to create a database named 'bugtest'.
The output should look like this:
Insert data
Update ok
Update fails on 0.9.4
Traceback (most recent call last):
File "bugtest.py", line 73, in <module>
trigger_bug(True)
File "bugtest.py", line 64, in trigger_bug
offending_update(session, parent)
File "bugtest.py", line 52, in offending_update
Child.name: "Doe",
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/query.py", line 2748, in update
update_op.exec_()
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/persistence.py", line 887, in exec_
self._do_pre_synchronize()
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/persistence.py", line 948, in _do_pre_synchronize
eval_condition(obj)]
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/evaluator.py", line 72, in evaluate
value = sub_evaluate(obj)
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/evaluator.py", line 97, in evaluate
left_val = eval_left(obj)
File "/Library/Python/2.7/site-packages/sqlalchemy/orm/evaluator.py", line 54, in <lambda>
return lambda obj: get_corresponding_attr(obj)
AttributeError: 'Child' object has no attribute 'parent_id'
Comments (3)
-
repo owner -
repo owner - The "evaulator" for query.update()/delete() won't work with multi-table
updates, and needs to be set to
synchronize_session=False
orsynchronize_session='fetch'
; this is a warning in 0.9.7, an exception in 1.0.
fixes
#3117→ <<cset 330800f7b8ec>>
- The "evaulator" for query.update()/delete() won't work with multi-table
updates, and needs to be set to
-
repo owner short version: use synchronize_session=False on your update statement. warning in 0.9.7 exception in 1.0.
- Log in to comment
synchronize_session=False
orsynchronize_session='fetch'
; this now raises an exception, with a message to change the synchronize setting. This will be only a warning in 0.9.7. fixes#3117→ <<cset e38bb315fdd2>>