From 48cba37764b129ff5ce52d93b025758cb104c4f2 Mon Sep 17 00:00:00 2001 From: Tobias Kroenke Date: Mon, 13 May 2019 10:08:28 +0200 Subject: [PATCH] remove migration ignore sql analysis --- django_migration_linter/migration_linter.py | 10 +----- django_migration_linter/sql_analyser.py | 40 +++++++-------------- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index 09814aa..d13edfd 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -108,15 +108,7 @@ class MigrationLinter(object): return sql_statements = self.get_sql(app_label, migration_name) - analysis_result = analyse_sql_statements(sql_statements) - errors = analysis_result["errors"] - - if analysis_result["ignored"]: - print("IGNORE") - self.nb_ignored += 1 - if self.should_use_cache(): - self.new_cache[md5hash] = {"result": "IGNORE"} - return + errors = analyse_sql_statements(sql_statements) if not errors: print("OK") diff --git a/django_migration_linter/sql_analyser.py b/django_migration_linter/sql_analyser.py index 65e4525..5c444de 100644 --- a/django_migration_linter/sql_analyser.py +++ b/django_migration_linter/sql_analyser.py @@ -15,10 +15,6 @@ import re import logging -from .operations import IGNORE_MIGRATION_SQL - -IGNORED_MIGRATION = "IGNORED_MIGRATION" - logger = logging.getLogger(__name__) @@ -71,36 +67,26 @@ migration_tests = ( ), }, {"code": "", "fn": has_default, "err_msg": ""}, - { - "code": IGNORED_MIGRATION, - "fn": lambda sql, **kw: re.search(IGNORE_MIGRATION_SQL, sql), - "err_msg": "", - }, ) def analyse_sql_statements(sql_statements): errors = [] - ignored = False for statement in sql_statements: for test in migration_tests: if test["fn"](statement, errors=errors): - if test["code"] == IGNORED_MIGRATION: - logger.debug("Testing {0} -- IGNORING MIGRATION".format(statement)) - ignored = True - else: - logger.debug("Testing {0} -- ERROR".format(statement)) - table_search = re.search( - "TABLE `([^`]*)`", statement, re.IGNORECASE - ) - col_search = re.search("COLUMN `([^`]*)`", statement, re.IGNORECASE) - err = { - "err_msg": test["err_msg"], - "code": test["code"], - "table": table_search.group(1) if table_search else None, - "column": col_search.group(1) if col_search else None, - } - errors.append(err) + logger.debug("Testing {0} -- ERROR".format(statement)) + table_search = re.search( + "TABLE `([^`]*)`", statement, re.IGNORECASE + ) + col_search = re.search("COLUMN `([^`]*)`", statement, re.IGNORECASE) + err = { + "err_msg": test["err_msg"], + "code": test["code"], + "table": table_search.group(1) if table_search else None, + "column": col_search.group(1) if col_search else None, + } + errors.append(err) else: logger.debug("Testing {0} -- PASSED".format(statement)) - return {"errors": errors, "ignored": ignored} + return errors