summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-04-07 17:51:34 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-04-07 17:52:23 -0400
commit26f1efcb055b70fe86a643338b65c849f9e2fa4e (patch)
treef0299de87e7363be1da59e145cd6cbe19105639f /test/sql
parent4d21920638af4729b6ff09b1ac8c3a20878bd922 (diff)
downloadsqlalchemy-26f1efcb055b70fe86a643338b65c849f9e2fa4e.tar.gz
support multivalues insert on strsqlcompiler
Fixed the "stringify" compiler to support a basic stringification of a "multirow" INSERT statement, i.e. one with multiple tuples following the VALUES keyword. Change-Id: I1fe38d204d9965275d3a72157d5a72a53bec4b11
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_compiler.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index d7a74ee2e..6cadda0bb 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -4415,6 +4415,17 @@ class StringifySpecialTest(fixtures.TestBase):
stmt = Column(Integer) == 5
eq_ignore_whitespace(str(stmt), '"<name unknown>" = :param_1')
+ def test_empty_insert(self):
+ stmt = table1.insert().values()
+ eq_ignore_whitespace(str(stmt), "INSERT INTO mytable () VALUES ()")
+
+ def test_multirow_insert(self):
+ stmt = table1.insert().values([{"myid": 1}, {"myid": 2}])
+ eq_ignore_whitespace(
+ str(stmt),
+ "INSERT INTO mytable (myid) VALUES (:myid_m0), (:myid_m1)",
+ )
+
def test_cte(self):
# stringify of these was supported anyway by defaultdialect.
stmt = select(table1.c.myid).cte()