Skip to content

Commit 5615d6d

Browse files
authored
Merge pull request #2139 from beginner0927/master
修改 #2134 Firebird 批量插入异常问题(BLOB SUB_TYPE TEXT需要参数化命令)。
2 parents 351e33d + 879dde5 commit 5615d6d

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Providers/FreeSql.Provider.Firebird/FirebirdUtils.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,30 @@ public override string GetNoneParamaterSqlValue(List<DbParameter> specialParams,
8888
{
8989
if (value == null) return "NULL";
9090
if (type.IsNumberType()) return string.Format(CultureInfo.InvariantCulture, "{0}", value);
91-
if (type == typeof(byte[])) return $"x'{CommonUtils.BytesSqlRaw(value as byte[])}'";
92-
if (type == typeof(string) && col != null && (specialParamFlag == "c" || specialParamFlag == "cu"))
93-
return $"cast('{value.ToString().Replace("'", "''")}' as {col.Attribute.DbType.Replace("NOT NULL", "").Replace("NULL", "")})"; //#1923
91+
if (type == typeof(byte[]))
92+
{
93+
if (col.Attribute.StringLength < 0)
94+
{
95+
var pam = AppendParamter(specialParams, $"p_{specialParams?.Count}{specialParamFlag}", null, type, value);
96+
return pam.ParameterName;
97+
}
98+
else
99+
{
100+
return $"x'{CommonUtils.BytesSqlRaw(value as byte[])}'";
101+
}
102+
}
103+
if (type == typeof(string))
104+
{
105+
if (col.Attribute.StringLength < 0)
106+
{
107+
var pam = AppendParamter(specialParams, $"p_{specialParams?.Count}{specialParamFlag}", null, type, value);
108+
return pam.ParameterName;
109+
}
110+
else if (col != null && (specialParamFlag == "c" || specialParamFlag == "cu"))
111+
{
112+
return $"cast('{value.ToString().Replace("'", "''")}' as {col.Attribute.DbType.Replace("NOT NULL", "").Replace("NULL", "")})"; //#1923
113+
}
114+
}
94115
return FormatSql("{0}", value, 1);
95116
}
96117
}

0 commit comments

Comments
 (0)