mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-10 10:20:55 +08:00
- 修复 Oracle CodeFirst clob/blob cast 转换问题;
This commit is contained in:
@@ -353,8 +353,9 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
|
||||
insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column);
|
||||
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
|
||||
{
|
||||
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "");
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim();
|
||||
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
}
|
||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
|
||||
insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})";
|
||||
|
||||
@@ -359,18 +359,11 @@ 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 (charMatch != null && ushort.TryParse(charMatch.Groups["precision"]?.Value, out var precision))
|
||||
dbtypeNoneNotNull = Regex.Replace(dbtypeNoneNotNull, $"\\(({precision})\\)", $"");
|
||||
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
}
|
||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
|
||||
insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})";
|
||||
|
||||
@@ -355,8 +355,9 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
|
||||
insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column);
|
||||
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
|
||||
{
|
||||
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "");
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim();
|
||||
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
}
|
||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
|
||||
insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})";
|
||||
|
||||
@@ -390,8 +390,9 @@ and not exists(select 1 from all_constraints where constraint_name = a.index_nam
|
||||
insertvalue = _commonUtils.QuoteSqlName(tbstructcol.column);
|
||||
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false)
|
||||
{
|
||||
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "");
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
var dbtypeNoneNotNull = Regex.Replace(tbcol.Attribute.DbType, @"(NOT\s+)?NULL", "").Trim();
|
||||
if (dbtypeNoneNotNull != "CLOB" && dbtypeNoneNotNull != "BLOB")
|
||||
insertvalue = $"cast({insertvalue} as {dbtypeNoneNotNull})";
|
||||
}
|
||||
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
|
||||
insertvalue = $"nvl({insertvalue},{tbcol.DbDefaultValue})";
|
||||
|
||||
Reference in New Issue
Block a user