summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sqlalchemy/orm/mapper.py16
-rw-r--r--lib/sqlalchemy/orm/properties.py2
-rw-r--r--test/aaa_profiling/test_orm.py4
3 files changed, 13 insertions, 9 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 54d6a53e2..05e904a0d 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -1833,13 +1833,15 @@ class Mapper(object):
if primary_key is not None:
# set primary key attributes
- for i, col in enumerate(mapper._pks_by_table[table]):
- if mapper._get_state_attr_by_column(
- state, state_dict, col) \
- is None and len(primary_key) > i:
- mapper._set_state_attr_by_column(
- state, state_dict, col,
- primary_key[i])
+ for pk, col in zip(primary_key, mapper._pks_by_table[table]):
+ # TODO: make sure this inlined code is OK
+ # with composites
+ prop = mapper._columntoproperty[col]
+ if state_dict.get(prop.key) is None:
+ # TODO: would rather say:
+ # state_dict[prop.key] = pk
+ # here, one test fails
+ prop._setattr(state, state_dict, pk, col)
mapper._postfetch(uowtransaction, table,
state, state_dict, c,
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index c2f88f9ed..776ecaf99 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -124,7 +124,7 @@ class ColumnProperty(StrategizedProperty):
get_committed_value(state, dict_, passive=passive)
def _setattr(self, state, dict_, value, column):
- state.get_impl(self.key).set(state, dict_, value, None)
+ state.manager[self.key].impl.set(state, dict_, value, None)
def merge(self, session, source_state, source_dict, dest_state,
dest_dict, load, _recursive):
diff --git a/test/aaa_profiling/test_orm.py b/test/aaa_profiling/test_orm.py
index bea66c072..a3bf81631 100644
--- a/test/aaa_profiling/test_orm.py
+++ b/test/aaa_profiling/test_orm.py
@@ -79,7 +79,9 @@ class MergeTest(_base.MappedTest):
# using sqlite3 the C extension took it back up to approx. 1257
# (py2.6)
- @profiling.function_call_count(1257, versions={'2.4': 807})
+ @profiling.function_call_count(1257,
+ versions={'2.6+cextension':1194, '2.4': 807}
+ )
def go():
p2 = sess2.merge(p1)
go()