summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-09-26 18:52:44 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-09-27 15:43:51 -0400
commitfe8ddb71d98f9f8b5e8e5bcf54b4208a1dfad2fd (patch)
treeb82d4ded4537a81d8c3b2325077f9c950ce1dde7 /lib/sqlalchemy
parent54768815c6471c4378c5ac57aa7090c68dc079dd (diff)
downloadsqlalchemy-fe8ddb71d98f9f8b5e8e5bcf54b4208a1dfad2fd.tar.gz
Remove MappedCollection converter; deprecate @converter
Removed the collection converter used by the :class:`.MappedCollection` class. This converter was used only to assert that the incoming dictionary keys matched that of their corresponding objects, and only during a bulk set operation. The converter can interfere with a custom validator or :meth:`.AttributeEvents.bulk_replace` listener that wants to convert incoming values further. The ``TypeError`` which would be raised by this converter when an incoming key didn't match the value is removed; incoming values during a bulk assignment will be keyed to their value-generated key, and not the key that's explicitly present in the dictionary. Overall, @converter is superseded by the :meth:`.AttributeEvents.bulk_replace` event handler added as part of :ticket:`3896`. Fixes: #3604 Change-Id: Id0f7bd2cec938f5975eb2ab94df9ba5754dd43c3
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/collections.py25
1 files changed, 1 insertions, 24 deletions
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py
index 5faff83a9..d6c23f5d2 100644
--- a/lib/sqlalchemy/orm/collections.py
+++ b/lib/sqlalchemy/orm/collections.py
@@ -442,6 +442,7 @@ class collection(object):
"""deprecated; synonym for :meth:`.collection.linker`."""
@staticmethod
+ @util.deprecated("1.3", "Use the bulk_replace event handler")
def converter(fn):
"""Tag the method as the collection converter.
@@ -1517,30 +1518,6 @@ class MappedCollection(dict):
(value, self[key], key))
self.__delitem__(key, _sa_initiator)
- @collection.converter
- def _convert(self, dictlike):
- """Validate and convert a dict-like object into values for set()ing.
-
- This is called behind the scenes when a MappedCollection is replaced
- entirely by another collection, as in::
-
- myobj.mappedcollection = {'a':obj1, 'b': obj2} # ...
-
- Raises a TypeError if the key in any (key, value) pair in the dictlike
- object does not match the key that this collection's keyfunc would
- have assigned for that value.
-
- """
- for incoming_key, value in util.dictlike_iteritems(dictlike):
- new_key = self.keyfunc(value)
- if incoming_key != new_key:
- raise TypeError(
- "Found incompatible key %r for value %r; this "
- "collection's "
- "keying function requires a key of %r for this value." % (
- incoming_key, value, new_key))
- yield value
-
# ensure instrumentation is associated with
# these built-in classes; if a user-defined class
# subclasses these and uses @internally_instrumented,