]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Modernize tests - legacy_select
authorGord Thompson <gord@gordthompson.com>
Wed, 14 Jul 2021 15:56:18 +0000 (09:56 -0600)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 21 Jul 2021 20:14:43 +0000 (16:14 -0400)
Change-Id: I04057cc3d3f93de60b02999803e2ba6a23cdf68d

17 files changed:
lib/sqlalchemy/testing/suite/test_unicode_ddl.py
lib/sqlalchemy/testing/warnings.py
test/dialect/mssql/test_compiler.py
test/dialect/mysql/test_for_update.py
test/dialect/postgresql/test_types.py
test/orm/test_deprecations.py
test/orm/test_froms.py
test/orm/test_unitofwork.py
test/sql/test_deprecations.py
test/sql/test_lambdas.py
test/sql/test_query.py
test/sql/test_quote.py
test/sql/test_resultset.py
test/sql/test_select.py
test/sql/test_selectable.py
test/sql/test_text.py
test/sql/test_types.py

index af6b382aeceb2eb5253d43243d41aff307b763af..a4ae3348ed6005e82bce4f7bb7ce46efb063e9c0 100644 (file)
@@ -161,19 +161,19 @@ class UnicodeSchemaTest(fixtures.TablesTest):
 
         eq_(
             connection.execute(
-                tt1.select(order_by=desc(u("méil")))
+                tt1.select().order_by(desc(u("méil")))
             ).fetchall(),
             [(2, 7), (1, 5)],
         )
         eq_(
             connection.execute(
-                tt2.select(order_by=desc(u("méil")))
+                tt2.select().order_by(desc(u("méil")))
             ).fetchall(),
             [(2, 2), (1, 1)],
         )
         eq_(
             connection.execute(
-                tt3.select(order_by=desc(ue("\u6e2c\u8a66_id")))
+                tt3.select().order_by(desc(ue("\u6e2c\u8a66_id")))
             ).fetchall(),
             [(2, 7, 2, 2), (1, 5, 1, 1)],
         )
index f8d6296a0c0dcf3d6857074f27bf649368e49d48..d60934afcd300a9eb22d0e90c918a44d4aa594c2 100644 (file)
@@ -68,8 +68,6 @@ def setup_filters():
         #
         # Core SQL constructs
         #
-        r"The legacy calling style of select\(\) is deprecated and will be "
-        "removed",
         r"The FromClause.select\(\) method will no longer accept keyword "
         "arguments in version 2.0",
         r"The Join.select\(\) method will no longer accept keyword arguments "
index f1f849bf95426e1f0353f5b9430c44db3e728b65..b0434115d68c8718b8b4fd9e523835b43ae9924d 100644 (file)
@@ -1069,7 +1069,13 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
         t = table("t", column("x", Integer), column("y", Integer))
 
         cols = [t.c.x, t.c.x.label("q"), t.c.x.label("p"), t.c.y]
-        s = select(cols).where(t.c.x == 5).order_by(t.c.y).limit(10).offset(20)
+        s = (
+            select(*cols)
+            .where(t.c.x == 5)
+            .order_by(t.c.y)
+            .limit(10)
+            .offset(20)
+        )
 
         self.assert_compile(
             s,
index 1708c075e9ddc69b6ee7b32c1970a3d4bc461975..4fdf9541ac301f343f8acca46435d00c8fa6a1dc 100644 (file)
@@ -282,9 +282,9 @@ class MySQLForUpdateCompileTest(fixtures.TestBase, AssertsCompiledSQL):
 
     def test_for_update_of_join_one(self):
         self.assert_compile(
-            self.join.select(self.table2.c.mytable_id == 7).with_for_update(
-                of=[self.join]
-            ),
+            self.join.select()
+            .where(self.table2.c.mytable_id == 7)
+            .with_for_update(of=[self.join]),
             "SELECT table2.mytable_id, "
             "mytable.myid, mytable.name, mytable.description "
             "FROM table2 "
@@ -312,9 +312,9 @@ class MySQLForUpdateCompileTest(fixtures.TestBase, AssertsCompiledSQL):
             ta, self.table2.c.mytable_id == ta.c.myid
         )
         self.assert_compile(
-            alias_join.select(self.table2.c.mytable_id == 7).with_for_update(
-                of=[alias_join]
-            ),
+            alias_join.select()
+            .where(self.table2.c.mytable_id == 7)
+            .with_for_update(of=[alias_join]),
             "SELECT table2.mytable_id, "
             "mytable_1.myid, mytable_1.name, mytable_1.description "
             "FROM table2 "
index 3fdb31b7cb5793967d65904bc1dcf5d2940379b6..f667a0223e5f033b950ff8cc83a9fd09c0843f66 100644 (file)
@@ -1587,7 +1587,7 @@ class ArrayRoundTripTest(object):
             ),
         )
         results = connection.execute(
-            arrtable.select(order_by=[arrtable.c.intarr])
+            arrtable.select().order_by(arrtable.c.intarr)
         ).fetchall()
         eq_(len(results), 2)
         eq_(results[0].strarr, [util.ue("m\xe4\xe4"), util.ue("m\xf6\xf6")])
index 2081f4f0a28fccde0047119d5e8bf81b8c229375..4f762e4b719765bff62b758223727867c81e27c6 100644 (file)
@@ -511,7 +511,8 @@ class DeprecatedQueryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(addresses)
-            .select(order_by=[text("ulist.id"), addresses.c.id])
+            .select()
+            .order_by(text("ulist.id"), addresses.c.id)
         )
         sess = fixture_session()
 
@@ -547,7 +548,8 @@ class DeprecatedQueryTest(_fixtures.FixtureTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(adalias)
-            .select(order_by=[text("ulist.id"), adalias.c.id])
+            .select()
+            .order_by(text("ulist.id"), adalias.c.id)
         )
 
         def go():
@@ -3304,7 +3306,8 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(addresses)
-            .select(order_by=[text("ulist.id"), addresses.c.id])
+            .select()
+            .order_by(text("ulist.id"), addresses.c.id)
         )
         sess = fixture_session()
         q = sess.query(User)
@@ -3334,9 +3337,11 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
 
         sess = fixture_session()
 
-        selectquery = users.outerjoin(addresses).select(
-            users.c.id < 10,
-            order_by=[users.c.id, addresses.c.id],
+        selectquery = (
+            users.outerjoin(addresses)
+            .select()
+            .where(users.c.id < 10)
+            .order_by(users.c.id, addresses.c.id)
         )
         q = sess.query(User)
 
@@ -3379,8 +3384,10 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
         q = sess.query(User)
 
         adalias = addresses.alias("adalias")
-        selectquery = users.outerjoin(adalias).select(
-            order_by=[users.c.id, adalias.c.id]
+        selectquery = (
+            users.outerjoin(adalias)
+            .select()
+            .order_by(users.c.id, adalias.c.id)
         )
 
         # note this has multiple problems because we aren't giving Query
@@ -3413,8 +3420,10 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
         q = sess.query(User)
 
         adalias = addresses.alias("adalias")
-        selectquery = users.outerjoin(adalias).select(
-            order_by=[users.c.id, adalias.c.id]
+        selectquery = (
+            users.outerjoin(adalias)
+            .select()
+            .order_by(users.c.id, adalias.c.id)
         )
 
         # note this has multiple problems because we aren't giving Query
index 9496f57bcf78e8ff04eacdc7eefdbe0eb7a9860d..0562dcb269997ad37b4fb107818298483294df1a 100644 (file)
@@ -356,7 +356,7 @@ class RawSelectTest(QueryTest, AssertsCompiledSQL):
         )
 
         self.assert_compile(
-            sess.query(users, exists([1], from_obj=addresses))
+            sess.query(users, exists(text("1")).select_from(addresses))
             .set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
             .statement,
             "SELECT users.id AS users_id, users.name AS users_name, EXISTS "
@@ -1083,7 +1083,8 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(addresses)
-            .select(order_by=[text("ulist.id"), addresses.c.id])
+            .select()
+            .order_by(text("ulist.id"), addresses.c.id)
         )
         sess = fixture_session()
         q = sess.query(User)
@@ -1111,7 +1112,8 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(addresses)
-            .select(order_by=[text("ulist.id"), addresses.c.id])
+            .select()
+            .order_by(text("ulist.id"), addresses.c.id)
         )
         sess = fixture_session()
         q = sess.query(User)
@@ -1141,7 +1143,8 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(addresses)
-            .select(order_by=[text("ulist.id"), addresses.c.id])
+            .select()
+            .order_by(text("ulist.id"), addresses.c.id)
         )
         sess = fixture_session()
 
@@ -1176,7 +1179,8 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
             .union(users.select().where(users.c.id > 7))
             .alias("ulist")
             .outerjoin(adalias)
-            .select(order_by=[text("ulist.id"), adalias.c.id])
+            .select()
+            .order_by(text("ulist.id"), adalias.c.id)
         )
 
         def go():
@@ -1251,9 +1255,11 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
 
         sess = fixture_session()
 
-        selectquery = users.outerjoin(addresses).select(
-            users.c.id < 10,
-            order_by=[users.c.id, addresses.c.id],
+        selectquery = (
+            users.outerjoin(addresses)
+            .select()
+            .where(users.c.id < 10)
+            .order_by(users.c.id, addresses.c.id)
         )
 
         q = sess.query(User)
@@ -1277,9 +1283,11 @@ class InstancesTest(QueryTest, AssertsCompiledSQL):
 
         sess = fixture_session(future=True)
 
-        selectquery = users.outerjoin(addresses).select(
-            users.c.id < 10,
-            order_by=[users.c.id, addresses.c.id],
+        selectquery = (
+            users.outerjoin(addresses)
+            .select()
+            .where(users.c.id < 10)
+            .order_by(users.c.id, addresses.c.id)
         )
 
         q = select(User)
@@ -2234,8 +2242,10 @@ class MixedEntitiesTest(QueryTest, AssertsCompiledSQL):
 
         sess = fixture_session(future=True)
 
-        selectquery = users.outerjoin(addresses).select(
-            order_by=[users.c.id, addresses.c.id]
+        selectquery = (
+            users.outerjoin(addresses)
+            .select()
+            .order_by(users.c.id, addresses.c.id)
         )
 
         result = sess.execute(
index 2f2586556dba1cc126fe8742d0a3db8f8a64a3bd..9cc39f79cfad20cd9c2b0f193f5b574b4fa2b2da 100644 (file)
@@ -1530,7 +1530,9 @@ class OneToManyTest(_fixtures.FixtureTest):
         eq_(list(user_rows[0]), [u.id, "one2manytester"])
 
         address_rows = conn.execute(
-            addresses.select(order_by=[addresses.c.email_address]).where(
+            addresses.select()
+            .order_by(addresses.c.email_address)
+            .where(
                 addresses.c.id.in_([a.id, a2.id]),
             )
         ).fetchall()
index 7b2b6c57e7b5aa54252d99b0fe24b25914c1fcaf..9f5deda9da1eb6adf2a4ec7abb22b234c97929a8 100644 (file)
@@ -2755,3 +2755,84 @@ class DDLDeprecatedBindTest(fixtures.TestBase):
             c1 = const(m1, bind=testing.db)
 
             is_(c1.bind, testing.db)
+
+
+class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL):
+    __dialect__ = "default"
+
+    @testing.fixture
+    def table_fixture(self):
+        table1 = table(
+            "mytable",
+            column("myid", Integer),
+            column("name", String),
+            column("description", String),
+        )
+
+        table2 = table(
+            "myothertable",
+            column("otherid", Integer),
+            column("othername", String),
+        )
+        return table1, table2
+
+    def test_legacy_calling_style_kw_only(self, table_fixture):
+        table1, table2 = table_fixture
+        with testing.expect_deprecated_20(
+            "The legacy calling style of select"
+        ):
+            stmt = select(
+                whereclause=table1.c.myid == table2.c.otherid
+            ).add_columns(table1.c.myid)
+
+            self.assert_compile(
+                stmt,
+                "SELECT mytable.myid FROM mytable, myothertable "
+                "WHERE mytable.myid = myothertable.otherid",
+            )
+
+    def test_legacy_calling_style_col_seq_only(self, table_fixture):
+        table1, table2 = table_fixture
+        with testing.expect_deprecated_20(
+            "The legacy calling style of select"
+        ):
+            # keep [] here
+            stmt = select([table1.c.myid]).where(
+                table1.c.myid == table2.c.otherid
+            )
+
+            self.assert_compile(
+                stmt,
+                "SELECT mytable.myid FROM mytable, myothertable "
+                "WHERE mytable.myid = myothertable.otherid",
+            )
+
+    def test_new_calling_style_thing_ok_actually_use_iter(self, table_fixture):
+        table1, table2 = table_fixture
+
+        class Thing(object):
+            def __iter__(self):
+                return iter([table1.c.name, table1.c.description])
+
+        with testing.expect_deprecated_20(
+            "The legacy calling style of select"
+        ):
+            stmt = select(Thing())
+            self.assert_compile(
+                stmt,
+                "SELECT mytable.name, mytable.description FROM mytable",
+            )
+
+    def test_kw_triggers_old_style(self, table_fixture):
+        table1, table2 = table_fixture
+        with testing.expect_deprecated_20(
+            "The legacy calling style of select"
+        ):
+            assert_raises_message(
+                exc.ArgumentError,
+                r"select\(\) construct created in legacy mode, "
+                "i.e. with keyword arguments",
+                select,
+                table1.c.myid,
+                whereclause=table1.c.myid == table2.c.otherid,
+            )
index 2de969521e41ab918759ff8c9bd776d9334fbc04..ea31c9aeca8c7dc0de519e56e8bd40b8d27fc1e1 100644 (file)
@@ -948,7 +948,7 @@ class LambdaElementTest(
             exc.ArgumentError,
             "Textual column expression 'f' should be explicitly declared",
             select,
-            [lambda: "foo"],
+            lambda: "foo",
         )
 
     def test_coercion_where_clause(self):
index 005693402db099c341897a8db3e14a4ac42adfca..0d81701132955ad40c1e5b744b3793f699ec52b5 100644 (file)
@@ -403,16 +403,16 @@ class QueryTest(fixtures.TablesTest):
                 return stmt
 
             a_eq(
-                users.select(order_by=[users.c.user_id]).set_label_style(
-                    label_style
-                ),
+                users.select()
+                .order_by(users.c.user_id)
+                .set_label_style(label_style),
                 [(1, "c"), (2, "b"), (3, "a")],
             )
 
             a_eq(
-                users.select(
-                    order_by=[users.c.user_name, users.c.user_id],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(users.c.user_name, users.c.user_id)
+                .set_label_style(label_style),
                 [(3, "a"), (2, "b"), (1, "c")],
             )
 
@@ -435,10 +435,10 @@ class QueryTest(fixtures.TablesTest):
             )
 
             a_eq(
-                users.select(
-                    distinct=True,
-                    order_by=[users.c.user_id],
-                ).set_label_style(label_style),
+                users.select()
+                .distinct()
+                .order_by(users.c.user_id)
+                .set_label_style(label_style),
                 [(1, "c"), (2, "b"), (3, "a")],
             )
 
@@ -463,10 +463,10 @@ class QueryTest(fixtures.TablesTest):
             )
 
             a_eq(
-                users.select(
-                    distinct=True,
-                    order_by=[desc(users.c.user_id)],
-                ).set_label_style(label_style),
+                users.select()
+                .distinct()
+                .order_by(desc(users.c.user_id))
+                .set_label_style(label_style),
                 [(3, "a"), (2, "b"), (1, "c")],
             )
 
@@ -503,75 +503,75 @@ class QueryTest(fixtures.TablesTest):
                 else LABEL_STYLE_TABLENAME_PLUS_COL
             )
             a_eq(
-                users.select(
-                    order_by=[users.c.user_name.nulls_first()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(users.c.user_name.nulls_first())
+                .set_label_style(label_style),
                 [(1, None), (3, "a"), (2, "b")],
             )
 
             a_eq(
-                users.select(
-                    order_by=[users.c.user_name.nulls_last()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(users.c.user_name.nulls_last())
+                .set_label_style(label_style),
                 [(3, "a"), (2, "b"), (1, None)],
             )
 
             a_eq(
-                users.select(
-                    order_by=[asc(users.c.user_name).nulls_first()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(asc(users.c.user_name).nulls_first())
+                .set_label_style(label_style),
                 [(1, None), (3, "a"), (2, "b")],
             )
 
             a_eq(
-                users.select(
-                    order_by=[asc(users.c.user_name).nulls_last()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(asc(users.c.user_name).nulls_last())
+                .set_label_style(label_style),
                 [(3, "a"), (2, "b"), (1, None)],
             )
 
             a_eq(
-                users.select(
-                    order_by=[users.c.user_name.desc().nulls_first()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(users.c.user_name.desc().nulls_first())
+                .set_label_style(label_style),
                 [(1, None), (2, "b"), (3, "a")],
             )
 
             a_eq(
-                users.select(
-                    order_by=[users.c.user_name.desc().nulls_last()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(users.c.user_name.desc().nulls_last())
+                .set_label_style(label_style),
                 [(2, "b"), (3, "a"), (1, None)],
             )
 
             a_eq(
-                users.select(
-                    order_by=[desc(users.c.user_name).nulls_first()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(desc(users.c.user_name).nulls_first())
+                .set_label_style(label_style),
                 [(1, None), (2, "b"), (3, "a")],
             )
 
             a_eq(
-                users.select(
-                    order_by=[desc(users.c.user_name).nulls_last()],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(desc(users.c.user_name).nulls_last())
+                .set_label_style(label_style),
                 [(2, "b"), (3, "a"), (1, None)],
             )
 
             a_eq(
-                users.select(
-                    order_by=[
-                        users.c.user_name.nulls_first(),
-                        users.c.user_id,
-                    ],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(
+                    users.c.user_name.nulls_first(),
+                    users.c.user_id,
+                )
+                .set_label_style(label_style),
                 [(1, None), (3, "a"), (2, "b")],
             )
 
             a_eq(
-                users.select(
-                    order_by=[users.c.user_name.nulls_last(), users.c.user_id],
-                ).set_label_style(label_style),
+                users.select()
+                .order_by(users.c.user_name.nulls_last(), users.c.user_id)
+                .set_label_style(label_style),
                 [(3, "a"), (2, "b"), (1, None)],
             )
 
@@ -1008,7 +1008,7 @@ class LimitTest(fixtures.TablesTest):
     def test_select_limit(self, connection):
         users, addresses = self.tables("users", "addresses")
         r = connection.execute(
-            users.select(limit=3, order_by=[users.c.user_id])
+            users.select().limit(3).order_by(users.c.user_id)
         ).fetchall()
         self.assert_(r == [(1, "john"), (2, "jack"), (3, "ed")], repr(r))
 
@@ -1019,11 +1019,11 @@ class LimitTest(fixtures.TablesTest):
         users, addresses = self.tables("users", "addresses")
 
         r = connection.execute(
-            users.select(limit=3, offset=2, order_by=[users.c.user_id])
+            users.select().limit(3).offset(2).order_by(users.c.user_id)
         ).fetchall()
         self.assert_(r == [(3, "ed"), (4, "wendy"), (5, "laura")])
         r = connection.execute(
-            users.select(offset=5, order_by=[users.c.user_id])
+            users.select().offset(5).order_by(users.c.user_id)
         ).fetchall()
         self.assert_(r == [(6, "ralph"), (7, "fido")])
 
index bf885a7f5560c40a7dfc3b2dd40a84e2c12bfc1a..e51bdf5a06128b75514d035698ac140fb6e5c43d 100644 (file)
@@ -145,11 +145,11 @@ class QuoteExecTest(fixtures.TablesTest):
             table1.c.MixedCase,
             table1.c.a123,
         ]
-        result = connection.execute(select(columns)).all()
+        result = connection.execute(select(*columns)).all()
         assert result == [(1, 2, 3, 4), (2, 2, 3, 4), (4, 3, 2, 1)]
 
         columns = [table2.c.d123, table2.c.u123, table2.c.MixedCase]
-        result = connection.execute(select(columns)).all()
+        result = connection.execute(select(*columns)).all()
         assert result == [(1, 2, 3), (2, 2, 3), (4, 3, 2)]
 
     def test_use_labels(self, connection):
@@ -178,13 +178,13 @@ class QuoteExecTest(fixtures.TablesTest):
             table1.c.a123,
         ]
         result = connection.execute(
-            select(columns).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
+            select(*columns).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
         ).fetchall()
         assert result == [(1, 2, 3, 4), (2, 2, 3, 4), (4, 3, 2, 1)]
 
         columns = [table2.c.d123, table2.c.u123, table2.c.MixedCase]
         result = connection.execute(
-            select(columns).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
+            select(*columns).set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL)
         ).all()
         assert result == [(1, 2, 3), (2, 2, 3), (4, 3, 2)]
 
@@ -232,7 +232,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
         )
 
         self.assert_compile(
-            table1.select(distinct=True).alias("LaLa").select(),
+            table1.select().distinct().alias("LaLa").select(),
             "SELECT "
             '"LaLa".lowercase, '
             '"LaLa"."UPPERCASE", '
@@ -669,7 +669,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
 
         # Note that 'col1' is already quoted (literal_column)
         columns = [sql.literal_column("'col1'").label("label1")]
-        x = select(columns, from_obj=[table]).alias("alias1")
+        x = select(*columns).select_from(table).alias("alias1")
         x = x.select()
         self.assert_compile(
             x,
@@ -688,7 +688,7 @@ class QuoteTest(fixtures.TestBase, AssertsCompiledSQL):
 
         # Note that 'Col1' is already quoted (literal_column)
         columns = [sql.literal_column("'Col1'").label("Label1")]
-        x = select(columns, from_obj=[table]).alias("Alias1")
+        x = select(*columns).select_from(table).alias("Alias1")
         x = x.select()
         self.assert_compile(
             x,
index e75ddeedea7eec7531302faf9adc9de23c1af3a9..936d0d9db977b6c228ad0b76d2221c0227e0c23c 100644 (file)
@@ -152,9 +152,7 @@ class CursorResultTest(fixtures.TablesTest):
             .where(users.c.user_name == "jack")
             .scalar_subquery()
         )
-        for row in connection.execute(
-            select([sel + 1, sel + 3], bind=users.bind)
-        ):
+        for row in connection.execute(select(sel + 1, sel + 3)):
             eq_(row._mapping["anon_1"], 8)
             eq_(row._mapping["anon_2"], 10)
 
@@ -2072,7 +2070,7 @@ class KeyTargetingTest(fixtures.TablesTest):
 
     def _adapt_result_columns_fixture_five(self):
         users, teams = self.tables("users", "teams")
-        return select([users.c.id, teams.c.id]).select_from(
+        return select(users.c.id, teams.c.id).select_from(
             users.outerjoin(teams)
         )
 
index 37d43f89f84f1aadb4412ca9be18e5bf6303f844..17b47d96de77549404dad65bb8d0e5eb2fab493c 100644 (file)
@@ -56,27 +56,6 @@ grandchild = Table(
 class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL):
     __dialect__ = "default"
 
-    def test_legacy_calling_style_kw_only(self):
-        stmt = select(
-            whereclause=table1.c.myid == table2.c.otherid
-        ).add_columns(table1.c.myid)
-
-        self.assert_compile(
-            stmt,
-            "SELECT mytable.myid FROM mytable, myothertable "
-            "WHERE mytable.myid = myothertable.otherid",
-        )
-
-    def test_legacy_calling_style_col_seq_only(self):
-        # keep [] here
-        stmt = select([table1.c.myid]).where(table1.c.myid == table2.c.otherid)
-
-        self.assert_compile(
-            stmt,
-            "SELECT mytable.myid FROM mytable, myothertable "
-            "WHERE mytable.myid = myothertable.otherid",
-        )
-
     def test_new_calling_style(self):
         stmt = select(table1.c.myid).where(table1.c.myid == table2.c.otherid)
 
@@ -123,28 +102,6 @@ class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL):
             "mytable.description FROM mytable",
         )
 
-    def test_new_calling_style_thing_ok_actually_use_iter(self):
-        class Thing(object):
-            def __iter__(self):
-                return iter([table1.c.name, table1.c.description])
-
-        stmt = select(Thing())
-        self.assert_compile(
-            stmt,
-            "SELECT mytable.name, mytable.description FROM mytable",
-        )
-
-    def test_kw_triggers_old_style(self):
-
-        assert_raises_message(
-            exc.ArgumentError,
-            r"select\(\) construct created in legacy mode, "
-            "i.e. with keyword arguments",
-            select,
-            table1.c.myid,
-            whereclause=table1.c.myid == table2.c.otherid,
-        )
-
     def test_join_nofrom_implicit_left_side_explicit_onclause(self):
         stmt = select(table1).join(table2, table1.c.myid == table2.c.otherid)
 
index cfdf4ad02ee884dea7514b601f48700ad2a66e5a..5d5c82714572e0798f76d2508aa392702dbc78e4 100644 (file)
@@ -3444,7 +3444,7 @@ class ResultMapTest(fixtures.TestBase):
         )
 
     def test_plain_exists(self):
-        expr = exists([1])
+        expr = exists(text("1"))
         eq_(type(expr.type), Boolean)
         eq_(
             [
@@ -3455,7 +3455,7 @@ class ResultMapTest(fixtures.TestBase):
         )
 
     def test_plain_exists_negate(self):
-        expr = ~exists([1])
+        expr = ~exists(text("1"))
         eq_(type(expr.type), Boolean)
         eq_(
             [
@@ -3466,7 +3466,7 @@ class ResultMapTest(fixtures.TestBase):
         )
 
     def test_plain_exists_double_negate(self):
-        expr = ~(~exists([1]))
+        expr = ~(~exists(text("1")))
         eq_(type(expr.type), Boolean)
         eq_(
             [
index 89cfa62c9f9092682a24b811e1dfcff80fdcd726..407e8aeb585692454803543793e719cf298bff4c 100644 (file)
@@ -768,13 +768,15 @@ class TextErrorsTest(fixtures.TestBase, AssertsCompiledSQL):
     __dialect__ = "default"
 
     def _test(self, fn, arg, offending_clause):
+        arg = util.to_list(arg)
+
         assert_raises_message(
             exc.ArgumentError,
             r"Textual (?:SQL|column|SQL FROM) expression %(stmt)r should be "
             r"explicitly declared (?:with|as) text\(%(stmt)r\)"
             % {"stmt": util.ellipses_string(offending_clause)},
             fn,
-            arg,
+            *arg
         )
 
     def test_where(self):
index 309baaabff7e1833ca89fe4b4a545168b68f8cef..88a51c0c63bb5218943221442575bc60666fb097 100644 (file)
@@ -2636,7 +2636,7 @@ class BinaryTest(fixtures.TablesTest, AssertsExecutionResults):
         )
 
         for stmt in (
-            binary_table.select(order_by=binary_table.c.primary_id),
+            binary_table.select().order_by(binary_table.c.primary_id),
             text(
                 "select * from binary_table order by binary_table.primary_id",
             ).columns(