After lots of inverstigation, i found the "passive_deletes" option that was missing from the whole discussion, and curiously not needed on our SA models to raise the exception. Your documentation, (and SA's as well) only illustrate on the cascade side.
reference found here: http://www.sqlalchemy.org/docs/reference/orm/mapping.html?highlight=relationship#sqlalchemy.orm.relationship it could be said that this is how deletion of the parent on a OneToMany relation is handled : 1- ondelete arguments on the ManyToOne side really only create referential integrity rules for that table in capable databases 2- cascade="all, merge, etc" on the OneToMany side enforces the chosen option on the application side 3- the default behaviour when a parent is deleted is SET NULL on all children 4-passive_deletes, if present and set to true/all on the OneToMany side, hands over referential integrity enforcement to the database dialect, implying either ondelete present in the schema, or a rule present in the database (or both) 5-with passive_deletes set to True on the OneToMany side, when a parent is deleted, the ondelete in the corresponding ManyToOne declaration or its table WILL be enforced (an exception will be raised if ondelete=="RESTRICT") for capable databases (which excludes SQLite <= 3.0 and MySQL ISAM) 6-with passive_deletes set to all, SET NULL on children will also be disabled. Issue solved. runnable code to test <code> from elixir import * metadata.bind = 'postgresql://localhost/testdb' metadata.bind.echo = True setup_all() create_all() class Person(Entity): name = Field(Unicode(60)) dogs = OneToMany("Dog", passive_deletes="all") def __repr__(self): return '<Person "%s">' % self.name class Dog(Entity): name = Field(Unicode(60)) master = ManyToOne("Person", ondelete="RESTRICT") def __repr__(self): return '<Dog "%s">' % self.name setup_all() create_all() john = Person(name=u"John") spike = Dog(name=u"Spike") pluto = Dog(name=u"Pluto") john.dogs.append(spike) john.dogs.append(pluto) print john.dogs session.delete(john) # below should break with IntegrityError try: session.flush() except IntegrityError, e: print "error was caught here:", "-"*9,"\n", e </code> -- You received this message because you are subscribed to the Google Groups "SQLElixir" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlelixir?hl=en.
