- 修复 Oracle CodeFirst clob/blob cast 转换问题;

This commit is contained in:
2881099
2025-02-10 19:00:14 +08:00
parent 2f32bb6165
commit 2695de562f
4 changed files with 13 additions and 17 deletions

View File

@@ -353,7 +353,8 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column); insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column);
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
{ {
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim();
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
} }
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)

View File

@@ -359,17 +359,10 @@ 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) if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
{ {
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "");
var charMatch = Regex.Match(dbtypeNoneNotNull, "(N?)VARCHAR(2?)\\((?<precision>[0-9]+)\\)"); var charMatch = Regex.Match(dbtypeNoneNotNull, "(N?)VARCHAR(2?)\\((?<precision>[0-9]+)\\)");
if (charMatch != null && ushort.TryParse(charMatch.Groups["precision"]?.Value, out var precision))
if(charMatch != null)
{
if (ushort.TryParse(charMatch.Groups["precision"]?.Value, out var precision))
{
dbtypeNoneNotNull = Regex.Replace(dbtypeNoneNotNull, $"\\(({precision})\\)", $""); dbtypeNoneNotNull = Regex.Replace(dbtypeNoneNotNull, $"\\(({precision})\\)", $"");
} if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
}
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
} }
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)

View File

@@ -355,7 +355,8 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column); insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column);
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
{ {
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim();
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
} }
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)

View File

@@ -390,7 +390,8 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column); insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column);
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false) if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
{ {
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", ""); var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim();
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})"; insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
} }
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable) if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)