On bulk update, the state is discarded at some point, causing an exception

Issue #3525 resolved
Berislav Lopac created an issue

I've asked about this issue on Stack Overflow: http://stackoverflow.com/questions/32407210/sqlalchemy-nonetype-object-has-no-attribute-expire-attributes-on-bulk-upda

However, I kept digging and have chased it to the persistence._bulk_update function, which replaces all states with None, causing the error shown in the SO question above. I've thrown together a brief patch which seems to fix the issue; will see if I can make a pull request out of it.

Comments (9)

  1. Mike Bayer repo owner
    • Fixed bug in :meth:.Session.bulk_save_objects where a mapped column that had some kind of "fetch on update" value and was not locally present in the given object would cause an AttributeError within the operation. fixes #3525

    → <<cset 68a6701c6d72>>

  2. Berislav Lopac reporter

    Hi Mike, sorry for not responding sooner, and thanks for taking care of that bug. I wasn't sure if it was intended to work that way (as the documentation states that the bulk methods don't support the relationships); it took me quite some time to figure out why is this happening.

  3. Log in to comment