]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add test for inserting multiple values
authorAthena Yao <athena.yao@cloverhealth.com>
Wed, 2 Mar 2016 19:43:09 +0000 (11:43 -0800)
committerAthena Yao <athena.yao@cloverhealth.com>
Wed, 2 Mar 2016 19:43:09 +0000 (11:43 -0800)
test/sql/test_insert.py

index 513757d5be0dbd8e0d8b24bc68fb660c42fc3408..315a567ef9de7d7a02940ec6892517777a9adead 100644 (file)
@@ -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