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 /lib/sqlalchemy/testing/suite/test_insert.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 'lib/sqlalchemy/testing/suite/test_insert.py')
-rw-r--r-- | lib/sqlalchemy/testing/suite/test_insert.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py index 5b8c343c4..74347cc77 100644 --- a/lib/sqlalchemy/testing/suite/test_insert.py +++ b/lib/sqlalchemy/testing/suite/test_insert.py @@ -55,7 +55,7 @@ class LastrowidTest(fixtures.TablesTest): r = connection.execute( self.tables.autoinc_pk.insert(), data="some data" ) - pk = connection.scalar(select([self.tables.autoinc_pk.c.id])) + pk = connection.scalar(select(self.tables.autoinc_pk.c.id)) eq_(r.inserted_primary_key, (pk,)) @requirements.dbapi_lastrowid @@ -64,7 +64,7 @@ class LastrowidTest(fixtures.TablesTest): self.tables.autoinc_pk.insert(), data="some data" ) lastrowid = r.lastrowid - pk = connection.scalar(select([self.tables.autoinc_pk.c.id])) + pk = connection.scalar(select(self.tables.autoinc_pk.c.id)) eq_(lastrowid, pk) @@ -178,7 +178,7 @@ class InsertBehaviorTest(fixtures.TablesTest): result = connection.execute( dest_table.insert().from_select( ("data",), - select([src_table.c.data]).where( + select(src_table.c.data).where( src_table.c.data.in_(["data2", "data3"]) ), ) @@ -187,7 +187,7 @@ class InsertBehaviorTest(fixtures.TablesTest): eq_(result.inserted_primary_key, (None,)) result = connection.execute( - select([dest_table.c.data]).order_by(dest_table.c.data) + select(dest_table.c.data).order_by(dest_table.c.data) ) eq_(result.fetchall(), [("data2",), ("data3",)]) @@ -199,7 +199,7 @@ class InsertBehaviorTest(fixtures.TablesTest): result = connection.execute( dest_table.insert().from_select( ("data",), - select([src_table.c.data]).where( + select(src_table.c.data).where( src_table.c.data.in_(["data2", "data3"]) ), ) @@ -207,7 +207,7 @@ class InsertBehaviorTest(fixtures.TablesTest): eq_(result.inserted_primary_key, (None,)) result = connection.execute( - select([dest_table.c.data]).order_by(dest_table.c.data) + select(dest_table.c.data).order_by(dest_table.c.data) ) eq_(result.fetchall(), []) @@ -227,7 +227,7 @@ class InsertBehaviorTest(fixtures.TablesTest): connection.execute( table.insert(inline=True).from_select( ("id", "data"), - select([table.c.id + 5, table.c.data]).where( + select(table.c.id + 5, table.c.data).where( table.c.data.in_(["data2", "data3"]) ), ) @@ -235,7 +235,7 @@ class InsertBehaviorTest(fixtures.TablesTest): eq_( connection.execute( - select([table.c.data]).order_by(table.c.data) + select(table.c.data).order_by(table.c.data) ).fetchall(), [("data1",), ("data2",), ("data2",), ("data3",), ("data3",)], ) @@ -255,7 +255,7 @@ class InsertBehaviorTest(fixtures.TablesTest): connection.execute( table.insert(inline=True).from_select( ("id", "data"), - select([table.c.id + 5, table.c.data]).where( + select(table.c.id + 5, table.c.data).where( table.c.data.in_(["data2", "data3"]) ), ) @@ -263,7 +263,7 @@ class InsertBehaviorTest(fixtures.TablesTest): eq_( connection.execute( - select([table]).order_by(table.c.data, table.c.id) + select(table).order_by(table.c.data, table.c.id) ).fetchall(), [ (1, "data1", 5, 4), @@ -306,7 +306,7 @@ class ReturningTest(fixtures.TablesTest): table.insert().returning(table.c.id), data="some data" ) pk = r.first()[0] - fetched_pk = connection.scalar(select([table.c.id])) + fetched_pk = connection.scalar(select(table.c.id)) eq_(fetched_pk, pk) def test_explicit_returning_pk_no_autocommit(self, connection): @@ -315,7 +315,7 @@ class ReturningTest(fixtures.TablesTest): table.insert().returning(table.c.id), data="some data" ) pk = r.first()[0] - fetched_pk = connection.scalar(select([table.c.id])) + fetched_pk = connection.scalar(select(table.c.id)) eq_(fetched_pk, pk) def test_autoincrement_on_insert_implicit_returning(self, connection): @@ -328,7 +328,7 @@ class ReturningTest(fixtures.TablesTest): r = connection.execute( self.tables.autoinc_pk.insert(), data="some data" ) - pk = connection.scalar(select([self.tables.autoinc_pk.c.id])) + pk = connection.scalar(select(self.tables.autoinc_pk.c.id)) eq_(r.inserted_primary_key, (pk,)) |