summaryrefslogtreecommitdiff
path: root/test/sql/test_insert.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sql/test_insert.py')
-rw-r--r--test/sql/test_insert.py32
1 files changed, 28 insertions, 4 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index 315a567ef..f2515c4eb 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -1,14 +1,13 @@
#! coding:utf-8
from sqlalchemy import Column, Integer, MetaData, String, Table,\
- bindparam, exc, func, insert, select, column, text
+ bindparam, exc, func, insert, select, column, text, table
from sqlalchemy.dialects import mysql, postgresql
from sqlalchemy.engine import default
from sqlalchemy.testing import AssertsCompiledSQL,\
assert_raises_message, fixtures, eq_
from sqlalchemy.sql import crud
-
class _InsertTestBase(object):
@classmethod
@@ -55,7 +54,32 @@ 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):
+ def test_unconsumed_names_kwargs(self):
+ t = table("t", column("x"), column("y"))
+ assert_raises_message(
+ exc.CompileError,
+ "Unconsumed column names: z",
+ t.insert().values(x=5, z=5).compile,
+ )
+
+ def test_bindparam_name_no_consume_error(self):
+ t = table("t", column("x"), column("y"))
+ # bindparam names don't get counted
+ i = t.insert().values(x=3 + bindparam('x2'))
+ self.assert_compile(
+ i,
+ "INSERT INTO t (x) VALUES ((:param_1 + :x2))"
+ )
+
+ # even if in the params list
+ i = t.insert().values(x=3 + bindparam('x2'))
+ self.assert_compile(
+ i,
+ "INSERT INTO t (x) VALUES ((:param_1 + :x2))",
+ params={"x2": 1}
+ )
+
+ def test_unconsumed_names_values_dict(self):
table1 = self.tables.mytable
checkparams = {
@@ -72,7 +96,7 @@ class InsertTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
dialect=postgresql.dialect()
)
- def test_insert_with_values_dict_unknown_column_multiple(self):
+ def test_unconsumed_names_multi_values_dict(self):
table1 = self.tables.mytable
checkparams = [{