[fix] 修复ref指向singleton表时,校验错误地使用了ref定义所在的字段而不是ref指向的表的字段的bug

main
walon 2023-05-06 13:04:44 +08:00
parent 4ef2d70398
commit 9bc74b3c73
1 changed files with 5 additions and 5 deletions

View File

@ -194,23 +194,23 @@ namespace Luban.Job.Cfg.Validators
//} //}
if (ct.IsOneValueTable) if (ct.IsOneValueTable)
{ {
if (string.IsNullOrEmpty(fieldName)) if (string.IsNullOrEmpty(indexName))
{ {
throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 是singleton表索引字段不能为空"); throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} 是singleton表索引字段不能为空");
} }
else else
{ {
if (!ct.ValueTType.Bean.TryGetField(fieldName, out var indexField, out _)) if (!ct.ValueTType.Bean.TryGetField(indexName, out var indexField, out _))
{ {
throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} value_type:{ct.ValueTType.Bean.FullName} 未包含索引字段:{fieldName}"); throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} value_type:{ct.ValueTType.Bean.FullName} 未包含索引字段:{indexName}");
} }
if (!(indexField.CType is TMap tmap)) if (!(indexField.CType is TMap tmap))
{ {
throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} value_type:{ct.ValueTType.Bean.FullName} 索引字段:{fieldName} type:{indexField.CType.TypeName} 不是map类型"); throw new Exception($"结构:{hostTypeName} 字段:{fieldName} ref:{actualTable} value_type:{ct.ValueTType.Bean.FullName} 索引字段:{indexName} type:{indexField.CType.TypeName} 不是map类型");
} }
if (tmap.KeyType.TypeName != Type.TypeName) if (tmap.KeyType.TypeName != Type.TypeName)
{ {
throw new Exception($"结构:{hostTypeName} 字段:{fieldName} 类型:'{Type.TypeName}' 与被引用的表:{actualTable} value_type:{ct.ValueTType.Bean.FullName} 索引字段:{fieldName} key_type:{tmap.KeyType.TypeName} 不一致"); throw new Exception($"结构:{hostTypeName} 字段:{fieldName} 类型:'{Type.TypeName}' 与被引用的表:{actualTable} value_type:{ct.ValueTType.Bean.FullName} 索引字段:{indexName} key_type:{tmap.KeyType.TypeName} 不一致");
} }
} }
} }