From 5cf8e14d58c89fdb94c60bf5e94d8b13d296da25 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 26 Jun 2019 11:45:50 -0400 Subject: Reflect "NO ACTION" as None; support "RESTRICT" The "NO ACTION" keyword for foreign key "ON UPDATE" is now considered to be the default cascade for a foreign key on all supporting backends (SQlite, MySQL, PostgreSQL) and when detected is not included in the reflection dictionary; this is already the behavior for PostgreSQL and MySQL for all previous SQLAlchemy versions in any case. The "RESTRICT" keyword is positively stored when detected; PostgreSQL does report on this keyword, and MySQL as of version 8.0 does as well. On earlier MySQL versions, it is not reported by the database. Fixes: #4741 Change-Id: I6becf1f2450605c1991158bb8a04d954dcc7396c --- lib/sqlalchemy/dialects/sqlite/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/dialects/sqlite/base.py') diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index d6a713988..b6ca8fe3c 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -1810,9 +1810,13 @@ class SQLiteDialect(default.DefaultDialect): for token in re.split(r" *\bON\b *", onupdatedelete.upper()): if token.startswith("DELETE"): - options["ondelete"] = token[6:].strip() + ondelete = token[6:].strip() + if ondelete and ondelete != "NO ACTION": + options["ondelete"] = ondelete elif token.startswith("UPDATE"): - options["onupdate"] = token[6:].strip() + onupdate = token[6:].strip() + if onupdate and onupdate != "NO ACTION": + options["onupdate"] = onupdate yield ( constraint_name, constrained_columns, -- cgit v1.2.1