From: Mike Bayer Date: Tue, 24 Apr 2012 20:27:58 +0000 (-0400) Subject: - [feature] The "unconsumed column names" warning emitted X-Git-Tag: rel_0_8_0b1~451 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a55d6c5f35769ea61ea5240aff9f763229d3007e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - [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] --- diff --git a/CHANGES b/CHANGES index 95ae66802c..113d54db65 100644 --- a/CHANGES +++ b/CHANGES @@ -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 218e48bcae..a58da176cd 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 d5d5eaa2d0..dfdf8bd873 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']