]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Handle multi-line check constraint definition extraction on SQLite. Fixes #11677.
authorJeff Horemans <jeff.horemans@vortex-financials.be>
Wed, 7 Aug 2024 11:09:00 +0000 (13:09 +0200)
committerJeff Horemans <jeff.horemans@vortex-financials.be>
Wed, 7 Aug 2024 11:09:00 +0000 (13:09 +0200)
lib/sqlalchemy/dialects/sqlite/base.py

index 04e84a68d2ea6b2b9465c70f5fbcaf38dc905bb6..25f8631b21f12c781273467ada8f3b4cdb7a2997 100644 (file)
@@ -2624,7 +2624,7 @@ class SQLiteDialect(default.DefaultDialect):
             connection, table_name, schema=schema, **kw
         )
 
-        CHECK_PATTERN = r"(?:CONSTRAINT (.+) +)?" r"CHECK *\( *(.+) *\),? *"
+        CHECK_PATTERN = r"(?:CONSTRAINT (.+) +)?CHECK *\( *((.|\n)+?) *\)(?:, ?\n|\n) *"
         cks = []
         # NOTE: we aren't using re.S here because we actually are
         # taking advantage of each CHECK constraint being all on one
@@ -2632,7 +2632,7 @@ class SQLiteDialect(default.DefaultDialect):
         # necessarily makes assumptions as to how the CREATE TABLE
         # was emitted.
 
-        for match in re.finditer(CHECK_PATTERN, table_data or "", re.I):
+        for match in re.finditer(CHECK_PATTERN, table_data or "", re.I|re.S):
             name = match.group(1)
 
             if name: