diff options
author | Athena Yao <athena.yao@cloverhealth.com> | 2016-03-02 11:43:09 -0800 |
---|---|---|
committer | Athena Yao <athena.yao@cloverhealth.com> | 2016-03-02 11:43:09 -0800 |
commit | a1de176d23ee03724ce269d143790686f862b400 (patch) | |
tree | 969fb40dcb705c5d046645bb7c9a66e87e1d6e47 /test/sql/test_insert.py | |
parent | 399f92cd116b747f742b919ac9a3e79eb0637e8a (diff) | |
download | sqlalchemy-a1de176d23ee03724ce269d143790686f862b400.tar.gz |
Add test for inserting multiple values
Diffstat (limited to 'test/sql/test_insert.py')
-rw-r--r-- | test/sql/test_insert.py | 38 |
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 |