Make sqlite and mysql table and column detection a little bit more resilient for UX
This commit is contained in:
1 parent
a31282a4d8
commit
1d9f4b7b86
2 files changed
+20
No files matched your search
@@ -27,3 +27,13 @@ class MySqlAnalyser(BaseAnalyser):
|
|||||||
"mode": "one_liner",
|
"mode": "one_liner",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def detect_column(sql):
|
||||||
|
if isinstance(sql, str):
|
||||||
|
regex_result = re.search("COLUMN [`\"'](.*?)[`\"']", sql, re.IGNORECASE)
|
||||||
|
if regex_result:
|
||||||
|
return regex_result.group(1)
|
||||||
|
regex_result = re.search("MODIFY [`\"'](.*?)[`\"']", sql, re.IGNORECASE)
|
||||||
|
if regex_result:
|
||||||
|
return regex_result.group(1)
|
||||||
@@ -67,3 +67,13 @@ class SqliteAnalyser(BaseAnalyser):
|
|||||||
},
|
},
|
||||||
{"code": "ADD_UNIQUE", "fn": has_add_unique, "mode": "transaction"},
|
{"code": "ADD_UNIQUE", "fn": has_add_unique, "mode": "transaction"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def detect_table(sql):
|
||||||
|
if isinstance(sql, str):
|
||||||
|
regex_result = re.search("TABLE [`\"'](.*?)[`\"']", sql, re.IGNORECASE)
|
||||||
|
if regex_result:
|
||||||
|
return regex_result.group(1)
|
||||||
|
regex_result = re.search("ON [`\"'](.*?)[`\"']", sql, re.IGNORECASE)
|
||||||
|
if regex_result:
|
||||||
|
return regex_result.group(1)
|
||||||
Reference in new issue
Block a user