summaryrefslogtreecommitdiff
path: root/test/sql/test_insert.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-19 15:18:22 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-19 15:18:22 -0500
commit77ed03652580c5db925729c573b76ca32393dc67 (patch)
tree634ae4d06624befb7a20bf22781ffe1c444a7afd /test/sql/test_insert.py
parentdd32540dabbee0678530fb1b0868d1eb41572dca (diff)
downloadsqlalchemy-77ed03652580c5db925729c573b76ca32393dc67.tar.gz
- Fixed bug where calling :meth:`.Insert.values` with an empty list
or tuple would raise an IndexError. It now produces an empty insert construct as would be the case with an empty dictionary.
Diffstat (limited to 'test/sql/test_insert.py')
-rw-r--r--test/sql/test_insert.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index 5c3b9b6c9..8a5c7cd83 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -244,6 +244,29 @@ class EmptyTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
"settings does not support empty inserts.",
stmt.compile, dialect=dialect)
+ def _test_insert_with_empty_collection_values(self, collection):
+ table1 = self.tables.mytable
+
+ ins = table1.insert().values(collection)
+
+ self.assert_compile(ins,
+ 'INSERT INTO mytable () VALUES ()',
+ checkparams={})
+
+ # empty dict populates on next values call
+ self.assert_compile(ins.values(myid=3),
+ 'INSERT INTO mytable (myid) VALUES (:myid)',
+ checkparams={'myid': 3})
+
+ def test_insert_with_empty_list_values(self):
+ self._test_insert_with_empty_collection_values([])
+
+ def test_insert_with_empty_dict_values(self):
+ self._test_insert_with_empty_collection_values({})
+
+ def test_insert_with_empty_tuple_values(self):
+ self._test_insert_with_empty_collection_values(())
+
class MultirowTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
__dialect__ = 'default'