Add logic to detect DROP TABLE
This commit is contained in:
1 parent
b79f9794ec
commit
4128c4b018
2 files changed
+16
No files matched your search
@@ -49,6 +49,12 @@ class BaseAnalyser(object):
|
||||
"err_msg": "DROPPING columns",
|
||||
"mode": "one_liner",
|
||||
},
|
||||
{
|
||||
"code": "DROP_TABLE",
|
||||
"fn": lambda sql, **kw: sql.startswith("DROP TABLE"),
|
||||
"err_msg": "DROPPING table",
|
||||
"mode": "one_liner",
|
||||
},
|
||||
{
|
||||
"code": "RENAME_COLUMN",
|
||||
"fn": lambda sql, **kw: re.search("ALTER TABLE .* CHANGE", sql)
|
||||
|
||||
@@ -25,6 +25,16 @@ class SqliteAnalyser(BaseAnalyser):
|
||||
and "__old" not in sql
|
||||
and "new__" not in sql,
|
||||
},
|
||||
{
|
||||
"code": "DROP_TABLE",
|
||||
# TODO: improve to detect that the table names overlap
|
||||
"fn": lambda sql_statements, **kw: any(
|
||||
sql.startswith("DROP TABLE") for sql in sql_statements
|
||||
)
|
||||
and not any(sql.startswith("CREATE TABLE") for sql in sql_statements),
|
||||
"err_msg": "DROPPING table",
|
||||
"mode": "transaction",
|
||||
},
|
||||
{
|
||||
"code": "NOT_NULL",
|
||||
"fn": lambda sql_statements, **kw: any(
|
||||
|
||||
Reference in new issue
Block a user