新增非法字段检查

This commit is contained in:
陈梓阳 2024-02-06 16:35:20 +08:00
parent d58c9d5177
commit 20cc78c667
3 changed files with 7 additions and 3 deletions

View File

@ -4,5 +4,5 @@ public static class ConstVar
{
public const string Producer = "Producer";
public const string Null = "NULL";
public const string MyDumperNull = "NULL";
public const string MyDumperNull = @"\N";
}

View File

@ -334,6 +334,8 @@ async Task RunProgram()
static void ReplaceIfMyDumperNull(DataRecord record, string fieldName, string replaceValue)
{
Log.Logger.Warning("发现不可空的字段为空({TableName}.{FieldName}),填充默认值: {DefaultValue}",
record.TableName, fieldName, replaceValue);
if (record[fieldName] is ConstVar.MyDumperNull)
record[fieldName] = replaceValue;
}
@ -359,7 +361,9 @@ async Task RunProgram()
break;
// OrderBlockPlan处理text->json列
case TableNames.OrderBlockPlan:
JsonDocument.Parse(record["OrderNos"]);
// 将所有值为'[]'(即字符串长度小等于2(16进制长度小于4))的置空 [] = 0x5b5d
if (record["OrderNos"].Length <= 4)
record["OrderNos"] = "NULL";
break;
// OrderBlockPlanResult添加CompanyID
case TableNames.OrderBlockPlanResult:

View File

@ -139,7 +139,7 @@ public partial class MySqlDestination : IDisposable, IAsyncDisposable
// 在这里处理特殊列
#region HandleFields
if (field.Length == 2 && field == @"\N") // MyDumper导出的NULL为'\N''\'不是转义字符)
if (field.Length == 2 && field == ConstVar.MyDumperNull) // MyDumper导出的NULL为'\N''\'不是转义字符)
{
recordSb.Append(ConstVar.Null);
goto Escape;