From: Mike Bayer Date: Fri, 10 Dec 2010 01:20:23 +0000 (-0500) Subject: - callcount X-Git-Tag: rel_0_7b1~184 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67259bfef1068b46ea72f04718de5bb514093dd2;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - callcount - more inlining --- diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 54d6a53e27..05e904a0de 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 c2f88f9ed0..776ecaf995 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 bea66c0723..a3bf816317 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()