SQL or invoke loader callables/initializers.
[ticket:2320]
+ - [bug] The warning emitted when using
+ delete-orphan cascade with one-to-many
+ or many-to-many without single-parent=True
+ is now an error. The ORM
+ would fail to function subsequent to this
+ warning in any case. [ticket:2405]
+
- [feature] Query now "auto correlates" by
default in the same way as select() does.
Previously, a Query used as a subquery
if self.cascade.delete_orphan and not self.single_parent \
and (self.direction is MANYTOMANY or self.direction
is MANYTOONE):
- util.warn('On %s, delete-orphan cascade is not supported '
+ raise sa_exc.ArgumentError(
+ 'On %s, delete-orphan cascade is not supported '
'on a many-to-many or many-to-one relationship '
'when single_parent is not set. Set '
'single_parent=True on the relationship().'
exc as sa_exc
from test.lib.schema import Table, Column
from sqlalchemy.orm import mapper, relationship, create_session, \
- sessionmaker, class_mapper, backref, Session, util as orm_util
+ sessionmaker, class_mapper, backref, Session, util as orm_util,\
+ configure_mappers
from sqlalchemy.orm import attributes, exc as orm_exc
from test.lib import testing
from test.lib.testing import eq_
assert b.count().scalar() == 0
assert a.count().scalar() == 0
+ def test_single_parent_error(self):
+ a, A, B, b, atob = (self.tables.a,
+ self.classes.A,
+ self.classes.B,
+ self.tables.b,
+ self.tables.atob)
+
+ mapper(A, a, properties={
+ 'bs':relationship(B, secondary=atob,
+ cascade="all, delete-orphan")
+ })
+ mapper(B, b)
+ assert_raises_message(
+ sa_exc.ArgumentError,
+ "On A.bs, delete-orphan cascade is not supported",
+ configure_mappers
+ )
+
def test_single_parent_raise(self):
a, A, B, b, atob = (self.tables.a,
self.classes.A,