Update Clickhouse array type bug

This commit is contained in:
sunkaixuan
2023-07-02 19:20:32 +08:00
parent 54e3a079ff
commit 5eaffa700e
2 changed files with 20 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ namespace SqlSugar.ClickHouse
} }
} }
int i = 0; int i = 0;
public object FormatValue(object value, string name) public object FormatValue(object value, string name,DbColumnInfo dbColumnInfo)
{ {
var n = ""; var n = "";
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar) if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
@@ -63,6 +63,14 @@ namespace SqlSugar.ClickHouse
return Convert.ToInt64(value); 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) else if (type == UtilConstants.BoolType)
{ {
return value.ObjToBool() ? "1" : "0"; return value.ObjToBool() ? "1" : "0";
@@ -144,7 +152,7 @@ namespace SqlSugar.ClickHouse
foreach (var item in groupList) foreach (var item in groupList)
{ {
batchInsetrSql.Append("("); 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); batchInsetrSql.Append(insertColumns);
if (groupList.Last() == item) if (groupList.Last() == item)
{ {

View File

@@ -114,9 +114,9 @@ namespace SqlSugar.ClickHouse
} }
private string GetOracleUpdateColums(int i, DbColumnInfo m, bool iswhere) 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) if (value == null)
{ {
@@ -158,6 +158,14 @@ namespace SqlSugar.ClickHouse
return Convert.ToInt64(value); 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) else if (type == UtilConstants.ByteArrayType)
{ {
var parameterName = this.Builder.SqlParameterKeyWord + name + i; var parameterName = this.Builder.SqlParameterKeyWord + name + i;