- Fixed bug in attribute history that inadvertently invoked
__eq__ on mapped instances.
+ - Fixed bug in session.merge() which prevented dict-like
+ collections from merging.
+
- sql
- Added math negation operator support, -x.
if self.uselist:
instances = source_state.get_impl(self.key).\
get(source_state, source_dict)
-
+ if hasattr(instances, '_sa_adapter'):
+ # convert collections to adapters to get a true iterator
+ instances = instances._sa_adapter
+
if load:
# for a full merge, pre-load the destination collection,
# so that individual _merge of each item pulls from identity
# down from 185 on this
# this is a small slice of a usually bigger
# operation so using a small variance
- @profiling.function_call_count(87, variance=0.001)
+ @profiling.function_call_count(91, variance=0.001)
def go():
return sess2.merge(p1, load=False)
from sqlalchemy.util import OrderedSet
from sqlalchemy.orm import mapper, relation, create_session, PropComparator, \
synonym, comparable_property, sessionmaker, attributes
+from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.orm.interfaces import MapperOption
from sqlalchemy.test.testing import eq_, ne_
from test.orm import _base, _fixtures
sess.merge(u1)
sess.flush()
assert u1.address_id is u1.data is None
-
+
+ @testing.resolve_artifact_names
+ def test_merge_irregular_collection(self):
+ mapper(User, users, properties={
+ 'addresses': relation(
+ mapper(Address, addresses),
+ backref='user',
+ collection_class=attribute_mapped_collection('email_address')),
+ })
+ u1 = User(id=7, name='fred')
+ u1.addresses['foo@bar.com'] = Address(email_address='foo@bar.com')
+ sess = create_session()
+ sess.merge(u1)
+ sess.flush()
+ assert u1.addresses.keys() == ['foo@bar.com']
+
@testing.resolve_artifact_names
def test_attribute_cascade(self):
"""Merge of a persistent entity with two child persistent entities."""