return [self._columntoproperty[col] for col in self.primary_key]
@_memoized_configured_property
- def _all_pk_props(self):
+ def _all_pk_cols(self):
collection = set()
for table in self.tables:
collection.update(self._pks_by_table[table])
@_memoized_configured_property
def _primary_key_propkeys(self):
- return {prop.key for prop in self._all_pk_props}
+ return {self._columntoproperty[col].key for col in self._all_pk_cols}
def _get_state_attr_by_column(
self, state, dict_, column, passive=attributes.PASSIVE_RETURN_NEVER_SET
)
)
- def test_update_keys(self):
- asserter = self._test_update(self.classes.PersonKeys)
+ @testing.combinations(
+ ("states",),
+ ("dicts",),
+ )
+ def test_update_keys(self, type_):
+ if type_ == "states":
+ asserter = self._test_update_states(self.classes.PersonKeys)
+ else:
+ asserter = self._test_update(self.classes.PersonKeys)
asserter.assert_(
CompiledSQL(
"UPDATE people_keys SET name=:personname "
)
)
+ @testing.combinations(
+ ("states",),
+ ("dicts",),
+ )
@testing.requires.updateable_autoincrement_pks
- def test_update_attrs(self):
- asserter = self._test_update(self.classes.PersonAttrs)
+ def test_update_attrs(self, type_):
+ if type_ == "states":
+ asserter = self._test_update_states(self.classes.PersonAttrs)
+ else:
+ asserter = self._test_update(self.classes.PersonAttrs)
asserter.assert_(
CompiledSQL(
"UPDATE people_attrs SET name=:name "
return asserter
+ def _test_update_states(self, person_cls):
+ Person = person_cls
+
+ s = Session()
+ s.add(Person(id=5, personname="thename"))
+ s.commit()
+
+ p = s.query(Person).get(5)
+ with self.sql_execution_asserter(testing.db) as asserter:
+ p.personname = "newname"
+ s.bulk_save_objects([p])
+
+ eq_(s.query(Person).first(), Person(id=5, personname="newname"))
+
+ return asserter
+
class BulkInheritanceTest(BulkTest, fixtures.MappedTest):
@classmethod