From c2ea2b7308a376640cf051d33c7f2f06373487c9 Mon Sep 17 00:00:00 2001 From: Gord Thompson Date: Wed, 14 Jul 2021 09:56:18 -0600 Subject: [PATCH] Modernize tests - legacy_select Change-Id: I04057cc3d3f93de60b02999803e2ba6a23cdf68d --- .../testing/suite/test_unicode_ddl.py | 6 +- lib/sqlalchemy/testing/warnings.py | 2 - test/dialect/mssql/test_compiler.py | 8 +- test/dialect/mysql/test_for_update.py | 12 +-- test/dialect/postgresql/test_types.py | 2 +- test/orm/test_deprecations.py | 29 +++-- test/orm/test_froms.py | 36 ++++--- test/orm/test_unitofwork.py | 4 +- test/sql/test_deprecations.py | 81 ++++++++++++++ test/sql/test_lambdas.py | 2 +- test/sql/test_query.py | 100 +++++++++--------- test/sql/test_quote.py | 14 +-- test/sql/test_resultset.py | 6 +- test/sql/test_select.py | 43 -------- test/sql/test_selectable.py | 6 +- test/sql/test_text.py | 4 +- test/sql/test_types.py | 2 +- 17 files changed, 210 insertions(+), 147 deletions(-) diff --git a/lib/sqlalchemy/testing/suite/test_unicode_ddl.py b/lib/sqlalchemy/testing/suite/test_unicode_ddl.py index af6b382aec..a4ae3348ed 100644 --- a/lib/sqlalchemy/testing/suite/test_unicode_ddl.py +++ b/lib/sqlalchemy/testing/suite/test_unicode_ddl.py @@ -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)], ) diff --git a/lib/sqlalchemy/testing/warnings.py b/lib/sqlalchemy/testing/warnings.py index f8d6296a0c..d60934afcd 100644 --- a/lib/sqlalchemy/testing/warnings.py +++ b/lib/sqlalchemy/testing/warnings.py @@ -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 " diff --git a/test/dialect/mssql/test_compiler.py b/test/dialect/mssql/test_compiler.py index f1f849bf95..b0434115d6 100644 --- a/test/dialect/mssql/test_compiler.py +++ b/test/dialect/mssql/test_compiler.py @@ -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, diff --git a/test/dialect/mysql/test_for_update.py b/test/dialect/mysql/test_for_update.py index 1708c075e9..4fdf9541ac 100644 --- a/test/dialect/mysql/test_for_update.py +++ b/test/dialect/mysql/test_for_update.py @@ -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 " diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 3fdb31b7cb..f667a0223e 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -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")]) diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index 2081f4f0a2..4f762e4b71 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -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 diff --git a/test/orm/test_froms.py b/test/orm/test_froms.py index 9496f57bcf..0562dcb269 100644 --- a/test/orm/test_froms.py +++ b/test/orm/test_froms.py @@ -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( diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py index 2f2586556d..9cc39f79cf 100644 --- a/test/orm/test_unitofwork.py +++ b/test/orm/test_unitofwork.py @@ -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() diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index 7b2b6c57e7..9f5deda9da 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -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, + ) diff --git a/test/sql/test_lambdas.py b/test/sql/test_lambdas.py index 2de969521e..ea31c9aeca 100644 --- a/test/sql/test_lambdas.py +++ b/test/sql/test_lambdas.py @@ -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): diff --git a/test/sql/test_query.py b/test/sql/test_query.py index 005693402d..0d81701132 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -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")]) diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index bf885a7f55..e51bdf5a06 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -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, diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index e75ddeedea..936d0d9db9 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -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) ) diff --git a/test/sql/test_select.py b/test/sql/test_select.py index 37d43f89f8..17b47d96de 100644 --- a/test/sql/test_select.py +++ b/test/sql/test_select.py @@ -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) diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py index cfdf4ad02e..5d5c827145 100644 --- a/test/sql/test_selectable.py +++ b/test/sql/test_selectable.py @@ -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_( [ diff --git a/test/sql/test_text.py b/test/sql/test_text.py index 89cfa62c9f..407e8aeb58 100644 --- a/test/sql/test_text.py +++ b/test/sql/test_text.py @@ -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): diff --git a/test/sql/test_types.py b/test/sql/test_types.py index 309baaabff..88a51c0c63 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -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( -- 2.47.2