修改Firebird 批量插入异常问题(BLOB SUB_TYPE TEXT需要参数化命令)。

This commit is contained in:
taojin
2025-11-03 11:22:08 +08:00
parent 351e33d010
commit 75edd97e28

View File

@@ -89,8 +89,18 @@ namespace FreeSql.Firebird
if (value == null) return "NULL";
if (type.IsNumberType()) return string.Format(CultureInfo.InvariantCulture, "{0}", value);
if (type == typeof(byte[])) return $"x'{CommonUtils.BytesSqlRaw(value as byte[])}'";
if (type == typeof(string) && col != null && (specialParamFlag == "c" || specialParamFlag == "cu"))
return $"cast('{value.ToString().Replace("'", "''")}' as {col.Attribute.DbType.Replace("NOT NULL", "").Replace("NULL", "")})"; //#1923
if (type == typeof(string))
{
if (col.Attribute.StringLength < 0)
{
var pam = AppendParamter(specialParams, $"p_{specialParams?.Count}{specialParamFlag}", null, type, value);
return pam.ParameterName;
}
else if (col != null && (specialParamFlag == "c" || specialParamFlag == "cu"))
{
return $"cast('{value.ToString().Replace("'", "''")}' as {col.Attribute.DbType.Replace("NOT NULL", "").Replace("NULL", "")})"; //#1923
}
}
return FormatSql("{0}", value, 1);
}
}