summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-02-22 17:57:17 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-02-22 17:57:17 +0000
commitca16c53651f819e9587ed29d7d1d7d937e7f25ce (patch)
treef85ea34dc4274c1821d0203879eb1e2c5c87e708 /test/sql
parentf1eb2921c762fef292a07e043b73881aaae476fa (diff)
parentffc375d1f02205838485dd1e3e181037b2c0a580 (diff)
downloadsqlalchemy-ca16c53651f819e9587ed29d7d1d7d937e7f25ce.tar.gz
Merge "Repair inline flag"
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_defaults.py2
-rw-r--r--test/sql/test_deprecations.py93
-rw-r--r--test/sql/test_insert.py30
-rw-r--r--test/sql/test_insert_exec.py8
-rw-r--r--test/sql/test_update.py11
5 files changed, 135 insertions, 9 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index ad27828a4..831f2a680 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -460,7 +460,7 @@ class DefaultTest(fixtures.TestBase):
set([t.c.col3, t.c.col5, t.c.col4, t.c.col6]),
)
- r = t.insert(inline=True).execute()
+ r = t.insert().inline().execute()
assert r.lastrow_has_defaults()
eq_(
set(r.context.postfetch_cols),
diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py
index ba6048f07..8bdba2793 100644
--- a/test/sql/test_deprecations.py
+++ b/test/sql/test_deprecations.py
@@ -1731,3 +1731,96 @@ class DefaultTest(fixtures.TestBase):
conn.execute(table.insert().values(x=5))
eq_(conn.execute(select([table])).first(), (5, 12))
+
+
+class DMLTest(fixtures.TestBase, AssertsCompiledSQL):
+ __dialect__ = "default"
+
+ def test_insert_inline_kw_defaults(self):
+ m = MetaData()
+ foo = Table("foo", m, Column("id", Integer))
+
+ t = Table(
+ "test",
+ m,
+ Column("col1", Integer, default=func.foo(1)),
+ Column(
+ "col2",
+ Integer,
+ default=select([func.coalesce(func.max(foo.c.id))]),
+ ),
+ )
+
+ with testing.expect_deprecated_20(
+ "The insert.inline parameter will be removed in SQLAlchemy 2.0."
+ ):
+ stmt = t.insert(inline=True, values={})
+
+ self.assert_compile(
+ stmt,
+ "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
+ "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
+ "foo))",
+ inline_flag=True,
+ )
+
+ def test_insert_inline_kw_default(self):
+ metadata = MetaData()
+ table = Table(
+ "sometable",
+ metadata,
+ Column("id", Integer, primary_key=True),
+ Column("foo", Integer, default=func.foobar()),
+ )
+
+ with testing.expect_deprecated_20(
+ "The insert.inline parameter will be removed in SQLAlchemy 2.0."
+ ):
+ stmt = table.insert(values={}, inline=True)
+
+ self.assert_compile(
+ stmt,
+ "INSERT INTO sometable (foo) VALUES (foobar())",
+ inline_flag=True,
+ )
+
+ with testing.expect_deprecated_20(
+ "The insert.inline parameter will be removed in SQLAlchemy 2.0."
+ ):
+ stmt = table.insert(inline=True)
+
+ self.assert_compile(
+ stmt,
+ "INSERT INTO sometable (foo) VALUES (foobar())",
+ params={},
+ inline_flag=True,
+ )
+
+ def test_update_inline_kw_defaults(self):
+ m = MetaData()
+ foo = Table("foo", m, Column("id", Integer))
+
+ t = Table(
+ "test",
+ m,
+ Column("col1", Integer, onupdate=func.foo(1)),
+ Column(
+ "col2",
+ Integer,
+ onupdate=select([func.coalesce(func.max(foo.c.id))]),
+ ),
+ Column("col3", String(30)),
+ )
+
+ with testing.expect_deprecated_20(
+ "The update.inline parameter will be removed in SQLAlchemy 2.0."
+ ):
+ stmt = t.update(inline=True, values={"col3": "foo"})
+
+ self.assert_compile(
+ stmt,
+ "UPDATE test SET col1=foo(:foo_1), col2=(SELECT "
+ "coalesce(max(foo.id)) AS coalesce_1 FROM foo), "
+ "col3=:col3",
+ inline_flag=True,
+ )
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index f4516f942..7508ee6c7 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -135,10 +135,19 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
)
self.assert_compile(
- t.insert(inline=True, values={}),
+ t.insert().values({}),
"INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
"(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
"foo))",
+ inline_flag=False,
+ )
+
+ self.assert_compile(
+ t.insert().inline().values({}),
+ "INSERT INTO test (col1, col2) VALUES (foo(:foo_1), "
+ "(SELECT coalesce(max(foo.id)) AS coalesce_1 FROM "
+ "foo))",
+ inline_flag=True,
)
def test_generic_insert_bind_params_all_columns(self):
@@ -290,14 +299,29 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
)
self.assert_compile(
- table.insert(values={}, inline=True),
+ table.insert().values(),
+ "INSERT INTO sometable (foo) VALUES (foobar())",
+ inline_flag=False,
+ )
+
+ self.assert_compile(
+ table.insert(),
+ "INSERT INTO sometable (foo) VALUES (foobar())",
+ params={},
+ inline_flag=False,
+ )
+
+ self.assert_compile(
+ table.insert().values().inline(),
"INSERT INTO sometable (foo) VALUES (foobar())",
+ inline_flag=True,
)
self.assert_compile(
- table.insert(inline=True),
+ table.insert().inline(),
"INSERT INTO sometable (foo) VALUES (foobar())",
params={},
+ inline_flag=True,
)
def test_insert_returning_not_in_default(self):
diff --git a/test/sql/test_insert_exec.py b/test/sql/test_insert_exec.py
index 2021c030c..9f9525f3c 100644
--- a/test/sql/test_insert_exec.py
+++ b/test/sql/test_insert_exec.py
@@ -338,7 +338,7 @@ class InsertExecTest(fixtures.TablesTest):
class TableInsertTest(fixtures.TablesTest):
"""test for consistent insert behavior across dialects
- regarding the inline=True flag, lower-case 't' tables.
+ regarding the inline() method, lower-case 't' tables.
"""
@@ -410,7 +410,7 @@ class TableInsertTest(fixtures.TablesTest):
def test_uppercase_inline(self):
t = self.tables.foo
self._test(
- t.insert(inline=True).values(id=1, data="data", x=5),
+ t.insert().inline().values(id=1, data="data", x=5),
(1, "data", 5),
inserted_primary_key=[1],
)
@@ -422,7 +422,7 @@ class TableInsertTest(fixtures.TablesTest):
def test_uppercase_inline_implicit(self):
t = self.tables.foo
self._test(
- t.insert(inline=True).values(data="data", x=5),
+ t.insert().inline().values(data="data", x=5),
(1, "data", 5),
inserted_primary_key=[None],
)
@@ -501,7 +501,7 @@ class TableInsertTest(fixtures.TablesTest):
def test_implicit_pk_inline(self):
t = self._fixture()
self._test(
- t.insert(inline=True).values(data="data", x=5),
+ t.insert().inline().values(data="data", x=5),
(1, "data", 5),
inserted_primary_key=[],
)
diff --git a/test/sql/test_update.py b/test/sql/test_update.py
index 68db6270f..78eecdf21 100644
--- a/test/sql/test_update.py
+++ b/test/sql/test_update.py
@@ -329,10 +329,19 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL):
)
self.assert_compile(
- t.update(inline=True, values={"col3": "foo"}),
+ t.update().values({"col3": "foo"}),
"UPDATE test SET col1=foo(:foo_1), col2=(SELECT "
"coalesce(max(foo.id)) AS coalesce_1 FROM foo), "
"col3=:col3",
+ inline_flag=False,
+ )
+
+ self.assert_compile(
+ t.update().inline().values({"col3": "foo"}),
+ "UPDATE test SET col1=foo(:foo_1), col2=(SELECT "
+ "coalesce(max(foo.id)) AS coalesce_1 FROM foo), "
+ "col3=:col3",
+ inline_flag=True,
)
def test_update_1(self):