diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-28 18:00:35 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-28 18:00:35 -0400 |
| commit | d6618e41195587291c4a82af0db43fbd993b6c77 (patch) | |
| tree | a93e608f2a145621ef19dfc869b78806e9b2f5bd /lib/sqlalchemy/orm/mapper.py | |
| parent | a0329f71ad48b16ad9dad44d5a5cb2c920e569f1 (diff) | |
| download | sqlalchemy-d6618e41195587291c4a82af0db43fbd993b6c77.tar.gz | |
- Added new parameter :paramref:`.mapper.confirm_deleted_rows`. Defaults
to True, indicates that a series of DELETE statements should confirm
that the cursor rowcount matches the number of primary keys that should
have matched; this behavior had been taken off in most cases
(except when version_id is used) to support the unusual edge case of
self-referential ON DELETE CASCADE; to accomodate this, the message
is now just a warning, not an exception, and the flag can be used
to indicate a mapping that expects self-refererntial cascaded
deletes of this nature. See also :ticket:`2403` for background on the
original change. re: #2403 fix #3007
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 4747c075d..a939cb9c7 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -110,6 +110,7 @@ class Mapper(_InspectionAttr): include_properties=None, exclude_properties=None, passive_updates=True, + confirm_deleted_rows=True, eager_defaults=False, legacy_is_orphan=False, _compiled_cache_size=100, @@ -208,6 +209,17 @@ class Mapper(_InspectionAttr): See the section :ref:`concrete_inheritance` for an example. + :param confirm_deleted_rows: defaults to True; when a DELETE occurs + of one more more rows based on specific primary keys, a warning is + emitted when the number of rows matched does not equal the number + of rows expected. This parameter may be set to False to handle the case + where database ON DELETE CASCADE rules may be deleting some of those + rows automatically. The warning may be changed to an exception + in a future release. + + .. versionadded:: 0.9.4 - added :paramref:`.mapper.confirm_deleted_rows` + as well as conditional matched row checking on delete. + :param eager_defaults: if True, the ORM will immediately fetch the value of server-generated default values after an INSERT or UPDATE, rather than leaving them as expired to be fetched on next access. @@ -545,9 +557,13 @@ class Mapper(_InspectionAttr): self._compiled_cache_size = _compiled_cache_size self._reconstructor = None self._deprecated_extensions = util.to_list(extension or []) - self.allow_partial_pks = allow_partial_pks + if self.inherits and not self.concrete: + self.confirm_deleted_rows = False + else: + self.confirm_deleted_rows = confirm_deleted_rows + self._set_with_polymorphic(with_polymorphic) if isinstance(self.local_table, expression.SelectBase): |
