fix:修复升级达梦数据库的表结构时由于select中字符串精读问题,而导致字符串截取的问题

This commit is contained in:
xieyidong
2024-11-13 16:54:03 +08:00
parent c986a1d9e1
commit e882269122
2 changed files with 80 additions and 0 deletions

View File

@@ -358,6 +358,17 @@ and not exists(select 1 from all_constraints where index_name = a.index_name and
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
{
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "");
var charMatch = Regex.Match(dbtypeNoneNotNull, "(N?)VARCHAR(2?)\\((?<precision>[0-9]+)\\)");
if(charMatch != null)
{
if (ushort.TryParse(charMatch.Groups["precision"]?.Value, out var precision))
{
dbtypeNoneNotNull = Regex.Replace(dbtypeNoneNotNull, $"\\(({precision})\\)", $"");
}
}
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
}
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)