include single table inh discriminator for query.update() / query.delete()?
ie session.query(Subclass).update(...) updates all rows in the table vs just Subclass rows.
Script attached that demonstrates the issue. There are two rows, only one should be updated, but both are updated.
Comments (3)
-
repo owner -
reporter Ok, thanks -- definitely missed it in the docs. It would be great if this were added. It was a couple weeks ago when I ran into this, and I can't remember if I was running an update or delete, but I have a feeling it was a delete and almost accidentally emptied the table.
-
repo owner - changed milestone to 1.3
- changed title to include single table inh discriminator for query.update() / query.delete()?
- marked as proposal
there may have been reasons other than backwards compat that this is not present. at the very least, we'd probably need to get #1653 in as the single-inh discriminator uses IN. One aspect here is that since we don't do the "joined" inheritance setup, we omit the single as well since the "spirit" of query.update() / query.delete() is that inheritance situations require special attention; having the single inh criteria be automatic here would conflict with that.
- Log in to comment
just had
#3902earlier today....again, this is a documented limitation:http://docs.sqlalchemy.org/en/latest/orm/query.html?highlight=query%20update#sqlalchemy.orm.query.Query.update
I suspect this may be a backwards compatibility issue and I'm pretty sure this could be added as an enhancement but for the moment it's not part of the usage contract and it's documented.