- establish consistent names between existing unconsumed names tests and new ones
added per ref #3666
'x2': 1,
'y': 2})
- def test_unconsumed_names(self):
- t = table("t", column("x"), column("y"))
- t2 = table("t2", column("q"), column("z"))
- assert_raises_message(
- exc.CompileError,
- "Unconsumed column names: z",
- t.insert().values(x=5, z=5).compile,
- )
- assert_raises_message(
- exc.CompileError,
- "Unconsumed column names: z",
- t.update().values(x=5, z=5).compile,
- )
-
- assert_raises_message(
- exc.CompileError,
- "Unconsumed column names: j",
- t.update().values(x=5, j=7).values({t2.c.z: 5}).
- where(t.c.x == t2.c.q).compile,
- )
-
- # 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}
- )
-
- assert_raises_message(
- exc.CompileError,
- "Unconsumed column names: j",
- t.update().values(x=5, j=7).compile,
- column_keys=['j']
- )
def test_labels_no_collision(self):
#! 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
'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 = {
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 = [{
-from sqlalchemy import *
+from sqlalchemy import Integer, String, ForeignKey, and_, or_, func, \
+ literal, update, table, bindparam, column, select, exc
from sqlalchemy import testing
from sqlalchemy.dialects import mysql
from sqlalchemy.engine import default
-from sqlalchemy.testing import AssertsCompiledSQL, eq_, fixtures
+from sqlalchemy.testing import AssertsCompiledSQL, eq_, fixtures, \
+ assert_raises_message
from sqlalchemy.testing.schema import Table, Column
from sqlalchemy import util
'mytable.myid = hoho(:hoho_1) AND '
'mytable.name = :param_2 || mytable.name || :param_3')
+ def test_unconsumed_names_kwargs(self):
+ t = table("t", column("x"), column("y"))
+
+ assert_raises_message(
+ exc.CompileError,
+ "Unconsumed column names: z",
+ t.update().values(x=5, z=5).compile,
+ )
+
+ def test_unconsumed_names_values_dict(self):
+ t = table("t", column("x"), column("y"))
+ t2 = table("t2", column("q"), column("z"))
+
+ assert_raises_message(
+ exc.CompileError,
+ "Unconsumed column names: j",
+ t.update().values(x=5, j=7).values({t2.c.z: 5}).
+ where(t.c.x == t2.c.q).compile,
+ )
+
+ def test_unconsumed_names_kwargs_w_keys(self):
+ t = table("t", column("x"), column("y"))
+
+ assert_raises_message(
+ exc.CompileError,
+ "Unconsumed column names: j",
+ t.update().values(x=5, j=7).compile,
+ column_keys=['j']
+ )
+
def test_update_ordered_parameters_1(self):
table1 = self.tables.mytable