]> 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:32:10 +0000 (19:32 -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.

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

index f137aebb7b34dcbe986243d3fe44fa2f93c51736..3460e5c6851c99e41483d1251c1e8b6e2bf00616 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 3c8d71331dbd8c8c7c6c05c2c2f091415fcfd4f0..1d38c9ad3c240219d63a6d114ae56b38eaa3a37e 100644 (file)
@@ -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)
 
index 4d9dc2bda702ca3016f38214fa294ca8620a0b00..6205ada34a1e5624d042fa72c63392d4d7ec892e 100644 (file)
@@ -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.
index ca24deb313be48c9d8965f5a72a60ed30ab60756..a5916c825659050e4dcec91e693b8b9d4e3235cb 100644 (file)
@@ -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
         )