summaryrefslogtreecommitdiff
path: root/test/orm/test_cascade.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-06-26 16:15:19 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-07-08 11:05:11 -0400
commit91f376692d472a5bf0c4b4033816250ec1ce3ab6 (patch)
tree31f7f72cbe981eb73ed0ba11808d4fb5ae6b7d51 /test/orm/test_cascade.py
parent3dc9a4a2392d033f9d1bd79dd6b6ecea6281a61c (diff)
downloadsqlalchemy-91f376692d472a5bf0c4b4033816250ec1ce3ab6.tar.gz
Add future=True to create_engine/Session; unify select()
Several weeks of using the future_select() construct has led to the proposal there be just one select() construct again which features the new join() method, and otherwise accepts both the 1.x and 2.x argument styles. This would make migration simpler and reduce confusion. However, confusion may be increased by the fact that select().join() is different Current thinking is we may be better off with a few hard behavioral changes to old and relatively unknown APIs rather than trying to play both sides within two extremely similar but subtly different APIs. At the moment, the .join() thing seems to be the only behavioral change that occurs without the user taking any explicit steps. Session.execute() will still behave the old way as we are adding a future flag. This change also adds the "future" flag to Session() and session.execute(), so that interpretation of the incoming statement, as well as that the new style result is returned, does not occur for existing applications unless they add the use of this flag. The change in general is moving the "removed in 2.0" system further along where we want the test suite to fully pass even if the SQLALCHEMY_WARN_20 flag is set. Get many tests to pass when SQLALCHEMY_WARN_20 is set; this should be ongoing after this patch merges. Improve the RemovedIn20 warning; these are all deprecated "since" 1.4, so ensure that's what the messages read. Make sure the inforamtion link is on all warnings. Add deprecation warnings for parameters present and add warnings to all FromClause.select() types of methods. Fixes: #5379 Fixes: #5284 Change-Id: I765a0b912b3dcd0e995426427d8bb7997cbffd51 References: #5159
Diffstat (limited to 'test/orm/test_cascade.py')
-rw-r--r--test/orm/test_cascade.py78
1 files changed, 39 insertions, 39 deletions
diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py
index 72d71635b..7e6db3b89 100644
--- a/test/orm/test_cascade.py
+++ b/test/orm/test_cascade.py
@@ -418,8 +418,8 @@ class O2MCascadeDeleteOrphanTest(fixtures.MappedTest):
sess.delete(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 0)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 0)
+ eq_(select(func.count("*")).select_from(users).scalar(), 0)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 0)
def test_delete_unloaded_collections(self):
"""Unloaded collections are still included in a delete-cascade
@@ -443,16 +443,16 @@ class O2MCascadeDeleteOrphanTest(fixtures.MappedTest):
sess.add(u)
sess.flush()
sess.expunge_all()
- eq_(select([func.count("*")]).select_from(addresses).scalar(), 2)
- eq_(select([func.count("*")]).select_from(users).scalar(), 1)
+ eq_(select(func.count("*")).select_from(addresses).scalar(), 2)
+ eq_(select(func.count("*")).select_from(users).scalar(), 1)
u = sess.query(User).get(u.id)
assert "addresses" not in u.__dict__
sess.delete(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(addresses).scalar(), 0)
- eq_(select([func.count("*")]).select_from(users).scalar(), 0)
+ eq_(select(func.count("*")).select_from(addresses).scalar(), 0)
+ eq_(select(func.count("*")).select_from(users).scalar(), 0)
def test_cascades_onlycollection(self):
"""Cascade only reaches instances that are still part of the
@@ -487,8 +487,8 @@ class O2MCascadeDeleteOrphanTest(fixtures.MappedTest):
sess.add(u2)
sess.flush()
sess.expunge_all()
- eq_(select([func.count("*")]).select_from(users).scalar(), 1)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 1)
+ eq_(select(func.count("*")).select_from(users).scalar(), 1)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 1)
eq_(
sess.query(User).all(),
[User(name="newuser", orders=[Order(description="someorder")])],
@@ -544,14 +544,14 @@ class O2MCascadeDeleteOrphanTest(fixtures.MappedTest):
)
sess.add(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 1)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 2)
+ eq_(select(func.count("*")).select_from(users).scalar(), 1)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 2)
del u.orders[0]
sess.delete(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 0)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 0)
+ eq_(select(func.count("*")).select_from(users).scalar(), 0)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 0)
def test_collection_orphans(self):
User, users, orders, Order = (
@@ -572,15 +572,15 @@ class O2MCascadeDeleteOrphanTest(fixtures.MappedTest):
sess.add(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 1)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 2)
+ eq_(select(func.count("*")).select_from(users).scalar(), 1)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 2)
u.orders[:] = []
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 1)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 0)
+ eq_(select(func.count("*")).select_from(users).scalar(), 1)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 0)
class O2MCascadeTest(fixtures.MappedTest):
@@ -725,14 +725,14 @@ class O2MCascadeDeleteNoOrphanTest(fixtures.MappedTest):
)
sess.add(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 1)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 2)
+ eq_(select(func.count("*")).select_from(users).scalar(), 1)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 2)
del u.orders[0]
sess.delete(u)
sess.flush()
- eq_(select([func.count("*")]).select_from(users).scalar(), 0)
- eq_(select([func.count("*")]).select_from(orders).scalar(), 1)
+ eq_(select(func.count("*")).select_from(users).scalar(), 0)
+ eq_(select(func.count("*")).select_from(orders).scalar(), 1)
class O2OSingleParentTest(_fixtures.FixtureTest):
@@ -1599,13 +1599,13 @@ class M2OCascadeDeleteOrphanTestOne(fixtures.MappedTest):
)
sess = create_session()
- eq_(select([func.count("*")]).select_from(prefs).scalar(), 3)
- eq_(select([func.count("*")]).select_from(extra).scalar(), 3)
+ eq_(select(func.count("*")).select_from(prefs).scalar(), 3)
+ eq_(select(func.count("*")).select_from(extra).scalar(), 3)
jack = sess.query(User).filter_by(name="jack").one()
jack.pref = None
sess.flush()
- eq_(select([func.count("*")]).select_from(prefs).scalar(), 2)
- eq_(select([func.count("*")]).select_from(extra).scalar(), 2)
+ eq_(select(func.count("*")).select_from(prefs).scalar(), 2)
+ eq_(select(func.count("*")).select_from(extra).scalar(), 2)
def test_cascade_on_deleted(self):
"""test a bug introduced by r6711"""
@@ -1670,8 +1670,8 @@ class M2OCascadeDeleteOrphanTestOne(fixtures.MappedTest):
assert p in sess
assert e in sess
sess.flush()
- eq_(select([func.count("*")]).select_from(prefs).scalar(), 2)
- eq_(select([func.count("*")]).select_from(extra).scalar(), 2)
+ eq_(select(func.count("*")).select_from(prefs).scalar(), 2)
+ eq_(select(func.count("*")).select_from(extra).scalar(), 2)
def test_pending_expunge(self):
Pref, User = self.classes.Pref, self.classes.User
@@ -2105,9 +2105,9 @@ class M2MCascadeTest(fixtures.MappedTest):
a1.bs.remove(b1)
sess.flush()
- eq_(select([func.count("*")]).select_from(atob).scalar(), 0)
- eq_(select([func.count("*")]).select_from(b).scalar(), 0)
- eq_(select([func.count("*")]).select_from(a).scalar(), 1)
+ eq_(select(func.count("*")).select_from(atob).scalar(), 0)
+ eq_(select(func.count("*")).select_from(b).scalar(), 0)
+ eq_(select(func.count("*")).select_from(a).scalar(), 1)
def test_delete_orphan_dynamic(self):
a, A, B, b, atob = (
@@ -2143,9 +2143,9 @@ class M2MCascadeTest(fixtures.MappedTest):
a1.bs.remove(b1)
sess.flush()
- eq_(select([func.count("*")]).select_from(atob).scalar(), 0)
- eq_(select([func.count("*")]).select_from(b).scalar(), 0)
- eq_(select([func.count("*")]).select_from(a).scalar(), 1)
+ eq_(select(func.count("*")).select_from(atob).scalar(), 0)
+ eq_(select(func.count("*")).select_from(b).scalar(), 0)
+ eq_(select(func.count("*")).select_from(a).scalar(), 1)
def test_delete_orphan_cascades(self):
a, A, c, b, C, B, atob = (
@@ -2187,10 +2187,10 @@ class M2MCascadeTest(fixtures.MappedTest):
a1.bs.remove(b1)
sess.flush()
- eq_(select([func.count("*")]).select_from(atob).scalar(), 0)
- eq_(select([func.count("*")]).select_from(b).scalar(), 0)
- eq_(select([func.count("*")]).select_from(a).scalar(), 1)
- eq_(select([func.count("*")]).select_from(c).scalar(), 0)
+ eq_(select(func.count("*")).select_from(atob).scalar(), 0)
+ eq_(select(func.count("*")).select_from(b).scalar(), 0)
+ eq_(select(func.count("*")).select_from(a).scalar(), 1)
+ eq_(select(func.count("*")).select_from(c).scalar(), 0)
def test_cascade_delete(self):
a, A, B, b, atob = (
@@ -2222,9 +2222,9 @@ class M2MCascadeTest(fixtures.MappedTest):
sess.delete(a1)
sess.flush()
- eq_(select([func.count("*")]).select_from(atob).scalar(), 0)
- eq_(select([func.count("*")]).select_from(b).scalar(), 0)
- eq_(select([func.count("*")]).select_from(a).scalar(), 0)
+ eq_(select(func.count("*")).select_from(atob).scalar(), 0)
+ eq_(select(func.count("*")).select_from(b).scalar(), 0)
+ eq_(select(func.count("*")).select_from(a).scalar(), 0)
def test_single_parent_error(self):
a, A, B, b, atob = (