diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-06-26 16:15:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-07-08 11:05:11 -0400 |
commit | 91f376692d472a5bf0c4b4033816250ec1ce3ab6 (patch) | |
tree | 31f7f72cbe981eb73ed0ba11808d4fb5ae6b7d51 /test/dialect/postgresql/test_compiler.py | |
parent | 3dc9a4a2392d033f9d1bd79dd6b6ecea6281a61c (diff) | |
download | sqlalchemy-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/dialect/postgresql/test_compiler.py')
-rw-r--r-- | test/dialect/postgresql/test_compiler.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 73d767602..20732067d 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -1192,7 +1192,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): Column("col1", Integer), Column("variadic", Integer), ) - x = select([table.c.col1, table.c.variadic]) + x = select(table.c.col1, table.c.variadic) self.assert_compile( x, """SELECT pg_table.col1, pg_table."variadic" FROM pg_table""" @@ -1453,19 +1453,19 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): expected = "SELECT foo.id FROM ONLY testtbl1 AS foo" self.assert_compile(stmt, expected) - stmt = select([tbl1, tbl2]).with_hint(tbl1, "ONLY", "postgresql") + stmt = select(tbl1, tbl2).with_hint(tbl1, "ONLY", "postgresql") expected = ( "SELECT testtbl1.id, testtbl2.id FROM ONLY testtbl1, " "testtbl2" ) self.assert_compile(stmt, expected) - stmt = select([tbl1, tbl2]).with_hint(tbl2, "ONLY", "postgresql") + stmt = select(tbl1, tbl2).with_hint(tbl2, "ONLY", "postgresql") expected = ( "SELECT testtbl1.id, testtbl2.id FROM testtbl1, ONLY " "testtbl2" ) self.assert_compile(stmt, expected) - stmt = select([tbl1, tbl2]) + stmt = select(tbl1, tbl2) stmt = stmt.with_hint(tbl1, "ONLY", "postgresql") stmt = stmt.with_hint(tbl2, "ONLY", "postgresql") expected = ( @@ -1502,7 +1502,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): m = MetaData() table = Table("table1", m, Column("a", Integer), Column("b", Integer)) expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc())) - stmt = select([expr]) + stmt = select(expr) # note this tests that the object exports FROM objects # correctly @@ -1518,7 +1518,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): expr = func.string_agg( table.c.a, aggregate_order_by(literal_column("','"), table.c.a) ) - stmt = select([expr]) + stmt = select(expr) self.assert_compile( stmt, @@ -1535,7 +1535,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): literal_column("','"), table.c.a, table.c.b.desc() ), ) - stmt = select([expr]) + stmt = select(expr) self.assert_compile( stmt, @@ -1593,7 +1593,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): m = MetaData() table = Table("table1", m, Column("a", Integer), Column("b", Integer)) expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc())) - stmt = select([expr]) + stmt = select(expr) a1 = table.alias("foo") stmt2 = sql_util.ClauseAdapter(a1).traverse(stmt) @@ -2005,7 +2005,7 @@ class InsertOnConflictTest(fixtures.TestBase, AssertsCompiledSQL): .cte("i_upsert") ) - stmt = select([i]) + stmt = select(i) self.assert_compile( stmt, @@ -2070,19 +2070,19 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): def test_plain_generative(self): self.assert_compile( - select([self.table]).distinct(), + select(self.table).distinct(), "SELECT DISTINCT t.id, t.a, t.b FROM t", ) def test_on_columns_generative(self): self.assert_compile( - select([self.table]).distinct(self.table.c.a), + select(self.table).distinct(self.table.c.a), "SELECT DISTINCT ON (t.a) t.id, t.a, t.b FROM t", ) def test_on_columns_generative_multi_call(self): self.assert_compile( - select([self.table]) + select(self.table) .distinct(self.table.c.a) .distinct(self.table.c.b), "SELECT DISTINCT ON (t.a, t.b) t.id, t.a, t.b FROM t", @@ -2111,7 +2111,7 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): def test_literal_binds(self): self.assert_compile( - select([self.table]).distinct(self.table.c.a == 10), + select(self.table).distinct(self.table.c.a == 10), "SELECT DISTINCT ON (t.a = 10) t.id, t.a, t.b FROM t", literal_binds=True, ) @@ -2172,9 +2172,9 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): def test_distinct_on_subquery_anon(self): - sq = select([self.table]).alias() + sq = select(self.table).alias() q = ( - select([self.table.c.id, sq.c.id]) + select(self.table.c.id, sq.c.id) .distinct(sq.c.id) .where(self.table.c.id == sq.c.id) ) @@ -2187,9 +2187,9 @@ class DistinctOnTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_distinct_on_subquery_named(self): - sq = select([self.table]).alias("sq") + sq = select(self.table).alias("sq") q = ( - select([self.table.c.id, sq.c.id]) + select(self.table.c.id, sq.c.id) .distinct(sq.c.id) .where(self.table.c.id == sq.c.id) ) @@ -2232,7 +2232,7 @@ class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): raise ValueError(c) def test_match_basic(self): - s = select([self.table_alt.c.id]).where( + s = select(self.table_alt.c.id).where( self.table_alt.c.title.match("somestring") ) self.assert_compile( @@ -2243,7 +2243,7 @@ class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_match_regconfig(self): - s = select([self.table_alt.c.id]).where( + s = select(self.table_alt.c.id).where( self.table_alt.c.title.match( "somestring", postgresql_regconfig="english" ) @@ -2256,7 +2256,7 @@ class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_match_tsvector(self): - s = select([self.table_alt.c.id]).where( + s = select(self.table_alt.c.id).where( func.to_tsvector(self.table_alt.c.title).match("somestring") ) self.assert_compile( @@ -2268,7 +2268,7 @@ class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_match_tsvectorconfig(self): - s = select([self.table_alt.c.id]).where( + s = select(self.table_alt.c.id).where( func.to_tsvector("english", self.table_alt.c.title).match( "somestring" ) @@ -2282,7 +2282,7 @@ class FullTextSearchTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_match_tsvectorconfig_regconfig(self): - s = select([self.table_alt.c.id]).where( + s = select(self.table_alt.c.id).where( func.to_tsvector("english", self.table_alt.c.title).match( "somestring", postgresql_regconfig="english" ) |