Hello, I’d like to get some clarification on the following two code examples. First, bulk delete <http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.delete> an object:
>>> u = dbsession.query(User).first() >>> u.id '0078ccdf7db046179c59bff01199c25e' >>> dbsession.query(User).filter(User.id == "0078ccdf7db046179c59bff01199c25e").delete() >>> dbsession.deleted IdentitySet([]) Note how the `deleted` set of the Session object is empty; the objects, however, aren’t yet deleted but will when the Session commits. The other way of deleting would be to delete the objects from the session <http://docs.sqlalchemy.org/en/latest/orm/session_api.html#sqlalchemy.orm.session.Session.delete> : >>> dbsession.delete(u) >>> dbsession.deleted IdentitySet([<User ORM object at 0x7fce2a0d6710 with id 0078ccdf7db046179c59bff01199c25e>, …]) There is a warning in the documentation of “bulk delete” which says that “[it] is a “bulk” operation, which bypasses ORM unit-of-work automation in favor of greater performance”. I think this refers to the above observation regarding the Session’s `deleted` set, but I don’t know what “unit-of-work automation” refers to. Can somebody please shed some light on the above observation? Also, is there a way to detect objects in a Session that are queued to be bulk-deleted? (This would a continuation of a previous discussion “Confusion over session.dirty, query, and flush” <https://groups.google.com/forum/#!topic/sqlalchemy/wZbHRPLE4ro>.) Thanks! Jens -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
