On Sep 20, 2011, at 11:53 AM, JPLaverdure wrote: > This fails because of the "nullable=False" clause on the Sample foreign key > as SQLA seems to try to update the sample to set box_id to null... > console printout: (from the delete portion)
I'm not sure this has anything to do with versioning ? This is just that the relationship "box" needs "cascade='all, delete-orphan'" on it so that Sample is marked for deletion rather than set null when its parent Box is deleted. > > 2011-09-20 11:41:51,021 INFO sqlalchemy.engine.base.Engine BEGIN (implicit) > 2011-09-20 11:41:51,022 INFO sqlalchemy.engine.base.Engine SELECT > test.container.type AS test_container_type, test.box.id AS test_box_id, > test.container.id AS test_container_id, test.container.token AS > test_container_token, test.container.description AS > test_container_description, test.container.version AS test_container_version, > test.box.barcode AS test_box_barcode > FROM test.container JOIN test.box ON test.container.id = test.box.id > WHERE test.container.id = %(param_1)s > 2011-09-20 11:41:51,023 INFO sqlalchemy.engine.base.Engine {'param_1': 1} > 2011-09-20 11:41:51,025 INFO sqlalchemy.engine.base.Engine SELECT > test.sample.id AS test_sample_id, test.sample.token AS test_sample_token, > test.sample.box_id AS test_sample_box_id, test.sample.version AS > test_sample_version > FROM test.sample > WHERE %(param_1)s = test.sample.box_id > 2011-09-20 11:41:51,025 INFO sqlalchemy.engine.base.Engine {'param_1': 1} > 2011-09-20 11:41:51,028 INFO sqlalchemy.engine.base.Engine INSERT INTO > test.container_history (id, type, token, description, version) VALUES > (%(id)s, %(type)s, %(token)s, %(description)s, %(version)s) > 2011-09-20 11:41:51,028 INFO sqlalchemy.engine.base.Engine {'token': u'Big > box', 'version': 1, 'type': u'box', 'id': 1, 'description': u'sample1'} > 2011-09-20 11:41:51,029 INFO sqlalchemy.engine.base.Engine INSERT INTO > test.box_history (id, barcode, version) VALUES (%(id)s, %(barcode)s, > %(version)s) > 2011-09-20 11:41:51,029 INFO sqlalchemy.engine.base.Engine {'barcode': u'', > 'id': 1, 'version': 1} > 2011-09-20 11:41:51,031 INFO sqlalchemy.engine.base.Engine UPDATE test.sample > SET box_id=%(box_id)s WHERE test.sample.id = %(test_sample_id)s > 2011-09-20 11:41:51,031 INFO sqlalchemy.engine.base.Engine {'box_id': None, > 'test_sample_id': 1} > 2011-09-20 11:41:51,032 INFO sqlalchemy.engine.base.Engine ROLLBACK > > > So it does indeed seem to visit the sample, but I must be doing something > wrong in my declaration because SQLA should be attempting to delete the > sample not update it ! > > Thanks > > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sqlalchemy/-/XAPy4uSlJAMJ. > To post to this group, send email to sqlalchemy@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.