diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2020-09-02 23:46:06 +0200 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-09-08 17:13:48 -0400 |
| commit | e8600608669d90c4a6385b312d271aed63eb5854 (patch) | |
| tree | ef984a01c536b2c81d2283b3ca5d9f4395f41dd0 /test/sql/test_update.py | |
| parent | 0d56a62f721ee6c91d8a8b6a407b959c9215b3b6 (diff) | |
| download | sqlalchemy-e8600608669d90c4a6385b312d271aed63eb5854.tar.gz | |
Update select usage to use the new 1.4 format
This change includes mainly that the bracketed use within
select() is moved to positional, and keyword arguments are
removed from calls to the select() function. it does not
yet fully address other issues such as keyword arguments passed
to the table.select().
Additionally, allows False / None to both be considered
as "disable" for all of select.correlate(), select.correlate_except(),
query.correlate(), which establishes consistency with
passing of ``False`` for the legact select(correlate=False)
argument.
Change-Id: Ie6c6e6abfbd3d75d4c8de504c0cf0159e6999108
Diffstat (limited to 'test/sql/test_update.py')
| -rw-r--r-- | test/sql/test_update.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/test/sql/test_update.py b/test/sql/test_update.py index 964e3ee6b..a5e57a78a 100644 --- a/test/sql/test_update.py +++ b/test/sql/test_update.py @@ -216,9 +216,9 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): u = update( table1, values={ - table1.c.name: select( - [mt.c.name], mt.c.myid == table1.c.myid - ).scalar_subquery() + table1.c.name: select(mt.c.name) + .where(mt.c.myid == table1.c.myid) + .scalar_subquery() }, ) self.assert_compile( @@ -233,9 +233,11 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): table2 = self.tables.myothertable # test against a regular constructed subquery - s = select( - [table2], table2.c.otherid == table1.c.myid - ).scalar_subquery() + s = ( + select(table2) + .where(table2.c.otherid == table1.c.myid) + .scalar_subquery() + ) u = update(table1, table1.c.name == "jack", values={table1.c.name: s}) self.assert_compile( u, @@ -250,7 +252,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): table2 = self.tables.myothertable # test a non-correlated WHERE clause - s = select([table2.c.othername], table2.c.otherid == 7) + s = select(table2.c.othername).where(table2.c.otherid == 7) u = update(table1, table1.c.name == s.scalar_subquery()) self.assert_compile( u, @@ -265,7 +267,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): table2 = self.tables.myothertable # test one that is actually correlated... - s = select([table2.c.othername], table2.c.otherid == table1.c.myid) + s = select(table2.c.othername).where(table2.c.otherid == table1.c.myid) u = table1.update(table1.c.name == s.scalar_subquery()) self.assert_compile( u, @@ -395,7 +397,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): Column( "col2", Integer, - onupdate=select([func.coalesce(func.max(foo.c.id))]), + onupdate=select(func.coalesce(func.max(foo.c.id))), ), Column("col3", String(30)), ) @@ -1005,7 +1007,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): cte = ( q.update().where(q.c.z == 1).values(x=7).returning(q.c.z).cte("c") ) - stmt = select([p.c.s, cte.c.z]).where(p.c.s == cte.c.z) + stmt = select(p.c.s, cte.c.z).where(p.c.s == cte.c.z) dialect = default.StrCompileDialect() dialect.paramstyle = "qmark" @@ -1026,7 +1028,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): """ table1 = self.tables.mytable table2 = self.tables.myothertable - sel = select([table2]).where(table2.c.otherid == 5).alias() + sel = select(table2).where(table2.c.otherid == 5).alias() upd = ( table1.update() .where(table1.c.name == sel.c.othername) |
