diff options
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 2 | ||||
-rw-r--r-- | test/sql/test_compiler.py | 8 |
3 files changed, 10 insertions, 5 deletions
@@ -176,6 +176,11 @@ CHANGES by setting "case_insensitive=False" on create_engine(). [ticket:2423] + - [feature] The "unconsumed column names" warning emitted + when keys are present in insert.values() or update.values() + that aren't in the target table is now an exception. + [ticket:2415] + - [bug] All of UniqueConstraint, ForeignKeyConstraint, CheckConstraint, and PrimaryKeyConstraint will attach themselves to their parent table automatically diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 218e48bca..a58da176c 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1411,7 +1411,7 @@ class SQLCompiler(engine.Compiled): sql._column_as_key(k) for k in stmt.parameters ).difference(check_columns) if check: - util.warn( + raise exc.CompileError( "Unconsumed column names: %s" % (", ".join(check)) ) diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index d5d5eaa2d..dfdf8bd87 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -3020,18 +3020,18 @@ class CRUDTest(fixtures.TestBase, AssertsCompiledSQL): t = table("t", column("x"), column("y")) t2 = table("t2", column("q"), column("z")) assert_raises_message( - exc.SAWarning, + exc.CompileError, "Unconsumed column names: z", t.insert().values(x=5, z=5).compile, ) assert_raises_message( - exc.SAWarning, + exc.CompileError, "Unconsumed column names: z", t.update().values(x=5, z=5).compile, ) assert_raises_message( - exc.SAWarning, + 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, @@ -3053,7 +3053,7 @@ class CRUDTest(fixtures.TestBase, AssertsCompiledSQL): ) assert_raises_message( - exc.SAWarning, + exc.CompileError, "Unconsumed column names: j", t.update().values(x=5, j=7).compile, column_keys=['j'] |