Browse Source

Update Clickhouse array type bug

pull/40/head
sunkaixuan 1 year ago
parent
commit
5eaffa700e
  1. 12
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseInsertBuilder.cs
  2. 12
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseUpdateBuilder.cs

12
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseInsertBuilder.cs

@ -25,7 +25,7 @@ namespace SqlSugar.ClickHouse
}
}
int i = 0;
public object FormatValue(object value, string name)
public object FormatValue(object value, string name,DbColumnInfo dbColumnInfo)
{
var n = "";
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
@ -63,6 +63,14 @@ namespace SqlSugar.ClickHouse
return Convert.ToInt64(value);
}
}
else if (dbColumnInfo.IsArray&& value!=null)
{
return n+"'"+this.Context.Utilities.SerializeObject(value)+"'";
}
else if (dbColumnInfo.IsJson && value != null)
{
return n + "'" + this.Context.Utilities.SerializeObject(value) + "'";
}
else if (type == UtilConstants.BoolType)
{
return value.ObjToBool() ? "1" : "0";
@ -144,7 +152,7 @@ namespace SqlSugar.ClickHouse
foreach (var item in groupList)
{
batchInsetrSql.Append("(");
insertColumns = string.Join(",", item.Select(it =>base.GetDbColumn(it, FormatValue(it.Value, it.PropertyName))));
insertColumns = string.Join(",", item.Select(it =>base.GetDbColumn(it, FormatValue(it.Value, it.PropertyName,it))));
batchInsetrSql.Append(insertColumns);
if (groupList.Last() == item)
{

12
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseUpdateBuilder.cs

@ -114,9 +114,9 @@ namespace SqlSugar.ClickHouse
}
private string GetOracleUpdateColums(int i, DbColumnInfo m, bool iswhere)
{
return string.Format("\"{0}\"={1}", m.DbColumnName, base.GetDbColumn(m,FormatValue(i, m.DbColumnName, m.Value, iswhere)));
return string.Format("\"{0}\"={1}", m.DbColumnName, base.GetDbColumn(m,FormatValue(i, m.DbColumnName, m.Value, iswhere,m)));
}
public object FormatValue(int i, string name, object value, bool iswhere)
public object FormatValue(int i, string name, object value, bool iswhere,DbColumnInfo dbColumnInfo)
{
if (value == null)
{
@ -158,6 +158,14 @@ namespace SqlSugar.ClickHouse
return Convert.ToInt64(value);
}
}
else if (dbColumnInfo.IsArray && value != null)
{
return n + "'" + this.Context.Utilities.SerializeObject(value) + "'";
}
else if (dbColumnInfo.IsJson && value != null)
{
return n + "'" + this.Context.Utilities.SerializeObject(value) + "'";
}
else if (type == UtilConstants.ByteArrayType)
{
var parameterName = this.Builder.SqlParameterKeyWord + name + i;

Loading…
Cancel
Save