Add internal classes and add type hints + mypy.
This commit is contained in:
1 parent
847ac1241a
commit
2ee7dac3b3
88 files changed
+603
-340
No files matched your search
@@ -1,22 +1,26 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from .base import BaseAnalyser
|
||||
from .base import BaseAnalyser, Check, CheckMode, CheckType
|
||||
|
||||
|
||||
class MySqlAnalyser(BaseAnalyser):
|
||||
migration_tests = [
|
||||
{
|
||||
"code": "ALTER_COLUMN",
|
||||
"fn": lambda sql, **kw: re.search(
|
||||
"ALTER TABLE .* MODIFY .* (?!NULL);?$", sql
|
||||
migration_checks: list[Check] = [
|
||||
Check(
|
||||
code="ALTER_COLUMN",
|
||||
fn=lambda sql, **kw: re.search("ALTER TABLE .* MODIFY .* (?!NULL);?$", sql),
|
||||
message=(
|
||||
"ALTERING columns (Could be backward compatible. "
|
||||
"You may ignore this migration.)"
|
||||
),
|
||||
"mode": "one_liner",
|
||||
"type": "error",
|
||||
}
|
||||
mode=CheckMode.ONE_LINER,
|
||||
type=CheckType.ERROR,
|
||||
),
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def detect_column(sql):
|
||||
def detect_column(sql: list[str] | str) -> str | None:
|
||||
if isinstance(sql, str):
|
||||
regex_result = re.search("COLUMN [`\"'](.*?)[`\"']", sql, re.IGNORECASE)
|
||||
if regex_result:
|
||||
@@ -24,3 +28,4 @@ class MySqlAnalyser(BaseAnalyser):
|
||||
regex_result = re.search("MODIFY [`\"'](.*?)[`\"']", sql, re.IGNORECASE)
|
||||
if regex_result:
|
||||
return regex_result.group(1)
|
||||
return None
|
||||
Reference in new issue
Block a user