新增非法字段检查

This commit is contained in:
2024-02-06 15:37:21 +08:00
parent 719cd2d8e7
commit d58c9d5177
8 changed files with 102 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
using System.Text;
using System.Text.RegularExpressions;
using MesETL.App.Const;
using MesETL.App.Helpers;
using MesETL.App.Options;
using Microsoft.Extensions.Logging;
@@ -138,10 +139,9 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
// 在这里处理特殊列
#region HandleFields
const string NULL = "NULL";
if (field.Length == 2 && field == @"\N") // MyDumper导出的NULL为'\N''\'不是转义字符)
{
recordSb.Append(NULL);
recordSb.Append(ConstVar.Null);
goto Escape;
}
@@ -150,15 +150,15 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
case ColumnType.Text:
if(string.IsNullOrEmpty(field))
recordSb.Append("''");
else if (field == NULL)
recordSb.Append(NULL);
else if (field == ConstVar.Null)
recordSb.Append(ConstVar.Null);
else recordSb.Append($"_utf8mb4 0x{field}");
break;
case ColumnType.Blob:
if (string.IsNullOrEmpty(field))
recordSb.Append("''");
else if (field == NULL)
recordSb.Append(NULL);
else if (field == ConstVar.Null)
recordSb.Append(ConstVar.Null);
else recordSb.Append($"0x{field}");
break;
case ColumnType.Json:// 生产库没有JSON列仅用于测试库进行测试