- Deferred column attributes no longer trigger a load operation when the
attribute is assigned to. In those cases, the newly assigned value
will be present in the flushes' UPDATE statement unconditionally.
-
+
- Fixed a truncation error when re-assigning a subset of a collection
(obj.relation = obj.relation[1:]) [ticket:834]
try:
return self._dest_primary_key
except AttributeError:
- self._dest_primary_key = self.dest_mapper is not None and self.dest_column in self.dest_mapper.pks_by_table[self.dest_column.table]
+ self._dest_primary_key = self.dest_mapper is not None and self.dest_column in self.dest_mapper.pks_by_table[self.dest_column.table] and not self.dest_mapper.allow_null_pks
return self._dest_primary_key
def execute(self, source, dest, obj, child, clearkeys):
assert False
except exceptions.AssertionError, e:
assert str(e).startswith("Dependency rule tried to blank-out primary key column 'B.id' on instance ")
+
+ def test_no_nullPK_sBtoA(self):
+ class A(object):pass
+ class B(object):pass
+ mapper(B, tableB, properties={
+ 'a':relation(A, cascade="save-update")
+ })
+ mapper(A, tableA)
+ b1 = B()
+ b1.a = None
+ sess = create_session()
+ sess.save(b1)
+ try:
+ # this raises an error as of r3695. in that rev, the attributes package was modified so that a
+ # setting of "None" shows up as a change, which in turn fires off dependency.py and then triggers
+ # the rule.
+ sess.flush()
+ assert False
+ except exceptions.AssertionError, e:
+ assert str(e).startswith("Dependency rule tried to blank-out primary key column 'B.id' on instance ")
+ def test_nullPKsOK_sBtoA(self):
+ class A(object):pass
+ class B(object):pass
+ mapper(B, tableB, properties={
+ 'a':relation(A, cascade="save-update")
+ }, allow_null_pks=True)
+ mapper(A, tableA)
+ b1 = B()
+ b1.a = None
+ sess = create_session()
+ sess.save(b1)
+ sess.flush()
+
def test_delete_cascade_BtoA(self):
"""test that the 'blank the PK' error doesnt get raised when the child is to be deleted as part of a
cascade"""