summaryrefslogtreecommitdiff
path: root/test/sql/test_insert.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-09-02 23:46:06 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-08 17:13:48 -0400
commite8600608669d90c4a6385b312d271aed63eb5854 (patch)
treeef984a01c536b2c81d2283b3ca5d9f4395f41dd0 /test/sql/test_insert.py
parent0d56a62f721ee6c91d8a8b6a407b959c9215b3b6 (diff)
downloadsqlalchemy-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_insert.py')
-rw-r--r--test/sql/test_insert.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index e5f2fbe6d..3cdf291ec 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -131,7 +131,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column(
"col2",
Integer,
- default=select([func.coalesce(func.max(foo.c.id))]),
+ default=select(func.coalesce(func.max(foo.c.id))),
),
)
@@ -332,7 +332,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_from_select_returning(self):
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = (
@@ -351,7 +351,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_from_select_select(self):
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = self.tables.myothertable.insert().from_select(
@@ -375,7 +375,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("data", String),
)
- stmt = t1.insert().from_select(("data",), select([t1.c.data]))
+ stmt = t1.insert().from_select(("data",), select(t1.c.data))
self.assert_compile(
stmt,
@@ -387,9 +387,9 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_from_select_cte_one(self):
table1 = self.tables.mytable
- cte = select([table1.c.name]).where(table1.c.name == "bar").cte()
+ cte = select(table1.c.name).where(table1.c.name == "bar").cte()
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == cte.c.name
)
@@ -413,9 +413,9 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
table1 = self.tables.mytable
- cte = select([table1.c.name]).where(table1.c.name == "bar").cte()
+ cte = select(table1.c.name).where(table1.c.name == "bar").cte()
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == cte.c.name
)
@@ -469,7 +469,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_from_select_select_alt_ordering(self):
table1 = self.tables.mytable
- sel = select([table1.c.name, table1.c.myid]).where(
+ sel = select(table1.c.name, table1.c.myid).where(
table1.c.name == "foo"
)
ins = self.tables.myothertable.insert().from_select(
@@ -492,7 +492,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("foo", Integer, default=func.foobar()),
)
table1 = self.tables.mytable
- sel = select([table1.c.myid]).where(table1.c.name == "foo")
+ sel = select(table1.c.myid).where(table1.c.name == "foo")
ins = table.insert().from_select(["id"], sel, include_defaults=False)
self.assert_compile(
ins,
@@ -510,7 +510,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("foo", Integer, default=func.foobar()),
)
table1 = self.tables.mytable
- sel = select([table1.c.myid]).where(table1.c.name == "foo")
+ sel = select(table1.c.myid).where(table1.c.name == "foo")
ins = table.insert().from_select(["id"], sel)
self.assert_compile(
ins,
@@ -529,7 +529,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("foo", Integer, default=12),
)
table1 = self.tables.mytable
- sel = select([table1.c.myid]).where(table1.c.name == "foo")
+ sel = select(table1.c.myid).where(table1.c.name == "foo")
ins = table.insert().from_select(["id"], sel)
self.assert_compile(
ins,
@@ -549,7 +549,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("foo", Integer, default=12),
)
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.myid.label("q")]).where(
+ sel = select(table1.c.myid, table1.c.myid.label("q")).where(
table1.c.name == "foo"
)
ins = table.insert().from_select(["id", "foo"], sel)
@@ -574,7 +574,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("foo", Integer, default=foo),
)
table1 = self.tables.mytable
- sel = select([table1.c.myid]).where(table1.c.name == "foo")
+ sel = select(table1.c.myid).where(table1.c.name == "foo")
ins = table.insert().from_select(["id"], sel)
self.assert_compile(
ins,
@@ -595,7 +595,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
Column("bar", String, default="baz"),
)
- stmt = select([table_.c.foo])
+ stmt = select(table_.c.foo)
insert = table_.insert().from_select(["foo"], stmt)
self.assert_compile(stmt, "SELECT mytable.foo FROM mytable")
@@ -613,7 +613,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_mix_select_values_exception(self):
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = self.tables.myothertable.insert().from_select(
@@ -628,7 +628,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_mix_values_select_exception(self):
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = self.tables.myothertable.insert().values(othername="5")
@@ -659,8 +659,8 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
name = column("name")
description = column("desc")
- sel = select([name, mytable.c.description]).union(
- select([name, description])
+ sel = select(name, mytable.c.description).union(
+ select(name, description)
)
ins = mytable.insert().from_select(
[mytable.c.name, mytable.c.description], sel
@@ -675,7 +675,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
def test_insert_from_select_col_values(self):
table1 = self.tables.mytable
table2 = self.tables.myothertable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = table2.insert().from_select(
@@ -831,7 +831,7 @@ class InsertImplicitReturningTest(
def test_insert_select(self):
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = self.tables.myothertable.insert().from_select(
@@ -847,7 +847,7 @@ class InsertImplicitReturningTest(
def test_insert_select_return_defaults(self):
table1 = self.tables.mytable
- sel = select([table1.c.myid, table1.c.name]).where(
+ sel = select(table1.c.myid, table1.c.name).where(
table1.c.name == "foo"
)
ins = (