]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Reinstate name party of SQLiteDialect's check constraint pattern, but made non-greedily.
authorJeff Horemans <jeff.horemans@vortex-financials.be>
Thu, 8 Aug 2024 08:35:45 +0000 (10:35 +0200)
committerJeff Horemans <jeff.horemans@vortex-financials.be>
Thu, 8 Aug 2024 08:35:45 +0000 (10:35 +0200)
lib/sqlalchemy/dialects/sqlite/base.py

index e001d0649e5018abb32946f047b2c09fda5a4a6a..976efdff775af91bb40588daccce6371cc7a65c2 100644 (file)
@@ -2626,12 +2626,12 @@ class SQLiteDialect(default.DefaultDialect):
 
         # Notes:
         # * The pattern currently matches any character for the name of the constraint
-        #   except tab and newline characters.
+        #   non greedily.
         # * Because check constraints in the table data can contain space, newline and tab characters,
         #   the pattern matches any character untill either the beginning of the next CONSTRAINT
         #   statement using a non-capturing non-consuming group (allowing the next one to match),
         #   or the end of the table definition e.g. newline and closing ')'.
-        CHECK_PATTERN = r"(?:CONSTRAINT ([^\t\n]+) )?CHECK \((.+?)\)(?:, *\n\t?(?=CONSTRAINT|CHECK)|\n\))"
+        CHECK_PATTERN = r"(?:CONSTRAINT (.+?) )?CHECK \((.+?)\)(?:, *\n\t?(?=CONSTRAINT|CHECK)|\n\))"
         cks = []
         for match in re.finditer(CHECK_PATTERN, table_data or "", re.I|re.S):
             name = match.group(1)