diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-16 19:32:10 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-16 19:34:48 -0500 |
| commit | 0fefc6e22641287100eb0648cf1264daeefeb020 (patch) | |
| tree | e6dd4699a625e68f57f1477a43069c2382c9cf12 | |
| parent | dcb7e7759ae85b2cc4d6a93fffd9746365ffe45a (diff) | |
| download | sqlalchemy-0fefc6e22641287100eb0648cf1264daeefeb020.tar.gz | |
- for [ticket:2651], leaving CheckConstraint alone, preferring to keep
backwards compatibility. A note about backslashing escapes is added.
Because the Text() construct now supports bind params better, the example
given in the code raises an exception now, so that should cover us.
The exception itself has been enhanced to include the key name of the
bound param. We're backporting this to 0.8 but 0.8 doesn't have the
text->bind behavior that raises.
Conflicts:
lib/sqlalchemy/sql/schema.py
| -rw-r--r-- | doc/build/changelog/changelog_08.rst | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/schema.py | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 5 | ||||
| -rw-r--r-- | test/sql/test_compiler.py | 3 |
4 files changed, 18 insertions, 4 deletions
diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index 9e8d2af1d..4141585e0 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -12,6 +12,14 @@ :version: 0.8.5 .. change:: + :tags: enhancement, sql + :versions: 0.9.0b2 + + The exception raised when a :class:`.BindParameter` is present + in a compiled statement without a value now includes the key name + of the bound parameter in the error message. + + .. change:: :tags: bug, orm :versions: 0.9.0b2 :tickets: 2887 diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index d623cf4d9..4d231d5ac 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -2133,7 +2133,11 @@ class CheckConstraint(Constraint): :param sqltext: A string containing the constraint definition, which will be used - verbatim, or a SQL expression construct. + verbatim, or a SQL expression construct. If given as a string, + the object is converted to a :class:`.Text` object. If the textual + string includes a colon character, escape this using a backslash:: + + CheckConstraint(r"foo ~ E'a(?\:b|c)d") :param name: Optional, the in-database name of the constraint. diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index d53753691..ad92396ee 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -786,8 +786,9 @@ class SQLCompiler(engine.Compiled): (within_columns_clause and \ self.ansi_bind_rules): if bindparam.value is None: - raise exc.CompileError("Bind parameter without a " - "renderable value not allowed here.") + raise exc.CompileError("Bind parameter '%s' without a " + "renderable value not allowed here." + % bindparam.key) return self.render_literal_bindparam(bindparam, within_columns_clause=True, **kwargs) diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index f35c6a7f8..b3451b9df 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1304,8 +1304,9 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): dialect=dialect ) - assert_raises( + assert_raises_message( exc.CompileError, + "Bind parameter 'foo' without a renderable value not allowed here.", bindparam("foo").in_([]).compile, dialect=dialect ) |
