schema工具更新了正则表达式逻辑

This commit is contained in:
xingheng 2025-09-08 13:16:11 +08:00
parent 0a1f2c458d
commit b1045def04
3 changed files with 4 additions and 4 deletions

View File

@ -528,8 +528,8 @@ WHERE
var subsql = sql.Split(';');
#region
// 正则表达式
string pattern = @"(?<=ALTER\s+TABLE\s+`)[^`]+";
string pattern2 = @"(?<=CREATE\s+TABLE\s+`)[^`]+";
string pattern = @"(?i)\balter\s+table\s+[`']?([a-zA-Z0-9_]+)[`']?";
string pattern2 = @"(?i)\bcreate\s+table\s+[`']?([a-zA-Z0-9_]+)[`']?";
int patternType;//1是create0是update
foreach (var sqlstr in subsql)
{
@ -554,7 +554,7 @@ WHERE
if (match.Length == 0 )
{
//无效的sql
LogInfo(baseDirectory + logFileName, $"无法从{SQLFILENAME}.sql文件中解析出正确的create table 或 update table。确保是有效的sql。文本为 {sqlstr}");
LogInfo(baseDirectory + logFileName, $"无法从{SQLFILENAME}文件中解析出正确的create table 或 update table。确保是有效的sql。文本为 {sqlstr}");
continue;
}
var groupMatch = Regex.Matches(sqlstr, pattern);

View File

@ -20,7 +20,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\..\..\IIS\SWS\UpgradeTool\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>