]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- repair param inject to work around code examples to some degree
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 5 Mar 2019 16:34:03 +0000 (11:34 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 5 Mar 2019 16:35:15 +0000 (11:35 -0500)
- link to correct text() construct for CheckConstraint

Change-Id: Ic46d1f79670a532f33bd9feb7f568dc3d1d6e38a

lib/sqlalchemy/sql/schema.py
lib/sqlalchemy/util/langhelpers.py

index 0d3e96d8ffeb2b7252673af6bb2e060a0d7d32dd..b045e006e7d9e491bb2287247706906b7be75a71 100644 (file)
@@ -2935,12 +2935,12 @@ class CheckConstraint(ColumnCollectionConstraint):
         r"""Construct a CHECK constraint.
 
         :param sqltext:
-          A string containing the constraint definition, which will be used
-          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::
+         A string containing the constraint definition, which will be used
+         verbatim, or a SQL expression construct.   If given as a string,
+         the object is converted to a :func:`.text` object. If the textual
+         string includes a colon character, escape this using a backslash::
 
-            CheckConstraint(r"foo ~ E'a(?\:b|c)d")
+           CheckConstraint(r"foo ~ E'a(?\:b|c)d")
 
         :param name:
           Optional, the in-database name of the constraint.
index 198a23a593fcff8b933ef8fb23ace17aed269425..efc950f1da2982b6d088e4f2927afa4bcfd1cdef 100644 (file)
@@ -1649,6 +1649,12 @@ def inject_param_text(doctext, inject_params):
             lines.append(to_inject)
             lines.append("\n")
             to_inject = None
+        elif line.endswith("::"):
+            # TODO: this still wont cover if the code example itself has blank
+            # lines in it, need to detect those via indentation.
+            lines.append(line)
+            lines.append(doclines.pop(0))  # the blank line following a code example
+            continue
         lines.append(line)
 
     return "\n".join(lines)