summaryrefslogtreecommitdiff
path: root/test/sql/test_insert.py
diff options
context:
space:
mode:
authorAthena Yao <athena.yao@cloverhealth.com>2016-03-02 11:43:09 -0800
committerAthena Yao <athena.yao@cloverhealth.com>2016-03-02 11:43:09 -0800
commita1de176d23ee03724ce269d143790686f862b400 (patch)
tree969fb40dcb705c5d046645bb7c9a66e87e1d6e47 /test/sql/test_insert.py
parent399f92cd116b747f742b919ac9a3e79eb0637e8a (diff)
downloadsqlalchemy-a1de176d23ee03724ce269d143790686f862b400.tar.gz
Add test for inserting multiple values
Diffstat (limited to 'test/sql/test_insert.py')
-rw-r--r--test/sql/test_insert.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index 513757d5b..315a567ef 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -55,6 +55,44 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
'INSERT INTO mytable (myid, name) VALUES (:myid, :name)',
checkparams=checkparams)
+ def test_insert_with_values_dict_unknown_column(self):
+ table1 = self.tables.mytable
+
+ checkparams = {
+ 'myid': 3,
+ 'name': 'jack',
+ 'unknowncol': 'oops'
+ }
+
+ stmt = insert(table1, values=checkparams)
+ assert_raises_message(
+ exc.CompileError,
+ 'Unconsumed column names: unknowncol',
+ stmt.compile,
+ dialect=postgresql.dialect()
+ )
+
+ def test_insert_with_values_dict_unknown_column_multiple(self):
+ table1 = self.tables.mytable
+
+ checkparams = [{
+ 'myid': 3,
+ 'name': 'jack',
+ 'unknowncol': 'oops'
+ }, {
+ 'myid': 4,
+ 'name': 'someone',
+ 'unknowncol': 'oops'
+ }]
+
+ stmt = insert(table1, values=checkparams)
+ assert_raises_message(
+ exc.CompileError,
+ 'Unconsumed column names: unknowncol',
+ stmt.compile,
+ dialect=postgresql.dialect()
+ )
+
def test_insert_with_values_tuple(self):
table1 = self.tables.mytable