diff options
| -rw-r--r-- | doc/build/changelog/changelog_08.rst | 8 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 5 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 6 | ||||
| -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 f137aebb7..3460e5c68 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/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 3c8d71331..1d38c9ad3 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -970,8 +970,9 @@ class SQLCompiler(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/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index 4d9dc2bda..6205ada34 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2272,7 +2272,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/test/sql/test_compiler.py b/test/sql/test_compiler.py index ca24deb31..a5916c825 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1174,8 +1174,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 ) |
