summaryrefslogtreecommitdiff
path: root/test/sql/test_deprecations.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-02-22 10:22:18 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-02-22 11:02:56 -0500
commitffc375d1f02205838485dd1e3e181037b2c0a580 (patch)
tree8fc6312600078cead3a0e8287f536c4fa4c31303 /test/sql/test_deprecations.py
parentf559f378c47811b5528ad1769cb86925e85fd1e5 (diff)
downloadsqlalchemy-ffc375d1f02205838485dd1e3e181037b2c0a580.tar.gz
Repair inline flag
In 9fca5d827d we attempted to deprecate the "inline=True" flag and add a generative inline() method, however failed to include any tests and the method was implemented incorrectly such that it would get overwritten with the boolean flag immediately. Rename the internal "inline" flag to "_inline" and add test support both for the method as well as deprecated support for the flag, including a fixture addition to assert the expected value of the flag as it generally does not affect the actual compiled SQL string. Change-Id: I0450049f17f1f0d91e22d27f1a973a2b6c0e59f7
Diffstat (limited to 'test/sql/test_deprecations.py')
-rw-r--r--test/sql/test_deprecations.py93
1 files changed, 93 insertions, 0 deletions
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,
+ )