diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-12 13:14:14 -0700 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-03-12 13:14:14 -0700 |
| commit | 6c03a8ddd366b62285e2671a25a429f7bff1d052 (patch) | |
| tree | 3ef6f29e6a2b04f6112345d501d10fd2a5f184fd /lib/sqlalchemy/orm | |
| parent | 5448f6129cd0487c3d06324385cc2ef0701b5815 (diff) | |
| download | sqlalchemy-6c03a8ddd366b62285e2671a25a429f7bff1d052.tar.gz | |
- add __table_cls__ option to declarative, not publicized yet, is for the moment
for the benefit of the test.lib.schema package.
- use test.lib.schema.Table for the table within test.lib.fixtures.DeclarativeMappedTest
- [bug] Removed the check for number of
rows affected when doing a multi-delete
against mapped objects. If an ON DELETE
CASCADE exists between two rows, we can't
get an accurate rowcount from the DBAPI;
this particular count is not supported
on most DBAPIs in any case, MySQLdb
is the notable case where it is.
[ticket:2403]
Diffstat (limited to 'lib/sqlalchemy/orm')
| -rw-r--r-- | lib/sqlalchemy/orm/persistence.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 31c9891b8..55b9bf84a 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -642,12 +642,10 @@ def _emit_delete_statements(base_mapper, uowtransaction, cached_connections, for connection, del_objects in delete.iteritems(): statement = base_mapper._memo(('delete', table), delete_stmt) - rows = -1 connection = cached_connections[connection] - if need_version_id and \ - not connection.dialect.supports_sane_multi_rowcount: + if need_version_id: # TODO: need test coverage for this [ticket:1761] if connection.dialect.supports_sane_rowcount: rows = 0 @@ -656,6 +654,12 @@ def _emit_delete_statements(base_mapper, uowtransaction, cached_connections, for params in del_objects: c = connection.execute(statement, params) rows += c.rowcount + if rows != len(del_objects): + raise orm_exc.StaleDataError( + "DELETE statement on table '%s' expected to " + "delete %d row(s); %d were matched." % + (table.description, len(del_objects), c.rowcount) + ) else: util.warn( "Dialect %s does not support deleted rowcount " @@ -664,16 +668,8 @@ def _emit_delete_statements(base_mapper, uowtransaction, cached_connections, stacklevel=12) connection.execute(statement, del_objects) else: - c = connection.execute(statement, del_objects) - if connection.dialect.supports_sane_multi_rowcount: - rows = c.rowcount + connection.execute(statement, del_objects) - if rows != -1 and rows != len(del_objects): - raise orm_exc.StaleDataError( - "DELETE statement on table '%s' expected to " - "delete %d row(s); %d were matched." % - (table.description, len(del_objects), c.rowcount) - ) def _finalize_insert_update_commands(base_mapper, uowtransaction, states_to_insert, states_to_update): |
