From 4fa4ae58743c435b2acde23ea890ca7c8b1b38f2 Mon Sep 17 00:00:00 2001 From: Jeff Horemans Date: Thu, 8 Aug 2024 09:57:26 +0200 Subject: [PATCH] Adjusted SQLiteDialect's check constraint reflection pattern to account for mix of named and unnamed constraints. --- lib/sqlalchemy/dialects/sqlite/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index a093065aee..61d6f8d8fa 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -2631,9 +2631,9 @@ class SQLiteDialect(default.DefaultDialect): # 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)|\n\))" + CHECK_PATTERN = r"(?:CONSTRAINT ([^\t\n]+) )?CHECK \((.+?)\)(?:, *\n\t?(?=CONSTRAINT|CHECK)|\n\))" cks = [] - + print(table_data) for match in re.finditer(CHECK_PATTERN, table_data or "", re.I|re.S): name = match.group(1) -- 2.47.3