]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- for [ticket:2651], leaving CheckConstraint alone, preferring to keep
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Dec 2013 00:32:10 +0000 (19:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Dec 2013 00:34:48 +0000 (19:34 -0500)
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

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/schema.py
lib/sqlalchemy/sql/compiler.py
test/sql/test_compiler.py

index 9e8d2af1d6ade1a92f320d795f9b290ee1c69289..4141585e0728f7f074ba72f0b08139c02cab22cf 100644 (file)
 .. changelog::
     :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
index d623cf4d9b9d768e4292c0765e7468a07767ba16..4d231d5acb96f5f120822ab38c8aa72b0eef369b 100644 (file)
@@ -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.
index d537536911bd3471e88db483bcc4d2d18f4caa58..ad92396eef9bcb7ad85bd2047a6be95de478561b 100644 (file)
@@ -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)
 
index f35c6a7f84f30600e5f31b5b75120468710bf765..b3451b9dfc8d8a76cfbe6ee7ba5ddb215f95ac12 100644 (file)
@@ -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
         )