Browse Source

Update clickhose array type

pull/32/head
sunkaixuan 2 years ago
parent
commit
71ea8cd018
  1. 5
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs

5
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs

@ -116,6 +116,7 @@ namespace SqlSugar.ClickHouse
CheckConnection(); CheckConnection();
ClickHouseCommand sqlCommand =connection.CreateCommand(); ClickHouseCommand sqlCommand =connection.CreateCommand();
var pars = ToIDbDataParameter(parameters); var pars = ToIDbDataParameter(parameters);
var arrayPars = parameters?.Where(it =>it.IsArray)?.Where(it=>it.ParameterName!=null)?.Select(it=>it.ParameterName);
foreach (var param in pars.OrderByDescending(it=>it.ParameterName.Length)) foreach (var param in pars.OrderByDescending(it=>it.ParameterName.Length))
{ {
var newName = param.ParameterName.TrimStart('@'); var newName = param.ParameterName.TrimStart('@');
@ -144,6 +145,10 @@ namespace SqlSugar.ClickHouse
{ {
sql = sql.Replace(param.ParameterName, "null"); sql = sql.Replace(param.ParameterName, "null");
} }
else if (arrayPars != null&& arrayPars.Contains(param.ParameterName))
{
sql= sql.Replace(param.ParameterName, "'" +this.Context.Utilities.SerializeObject(param.Value).ToSqlFilter() + "'");
}
else else
{ {
sql = sql.Replace(param.ParameterName, "{" + newName + ":" + dbtype + "}"); sql = sql.Replace(param.ParameterName, "{" + newName + ":" + dbtype + "}");

Loading…
Cancel
Save