mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
Clickhouse 数组参数化测试
This commit is contained in:
@ -85,7 +85,7 @@ namespace FreeSql.ClickHouse
|
||||
trydc.defaultValue);
|
||||
|
||||
//判断是否是集合
|
||||
var isCollection = IsCollection(type);
|
||||
var isCollection = IsArray(type);
|
||||
if (isCollection.Item1)
|
||||
{
|
||||
var genericType = isCollection.Item2;
|
||||
@ -102,6 +102,21 @@ namespace FreeSql.ClickHouse
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Tuple<bool, Type> IsArray(Type type)
|
||||
{
|
||||
var flag = false;
|
||||
Type resultType = null;
|
||||
|
||||
if (type.IsArray)
|
||||
{
|
||||
flag = true;
|
||||
resultType = type.GetElementType();
|
||||
}
|
||||
|
||||
return new Tuple<bool, Type>(flag, resultType);
|
||||
}
|
||||
|
||||
private Tuple<bool, Type> IsCollection(Type type)
|
||||
{
|
||||
var flag = false;
|
||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Globalization;
|
||||
using System.Data;
|
||||
using System.Text.Json;
|
||||
using ClickHouse.Client.ADO.Parameters;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@ -18,7 +19,7 @@ namespace FreeSql.ClickHouse
|
||||
}
|
||||
|
||||
public override DbParameter AppendParamter(List<DbParameter> _params, string parameterName, ColumnInfo col, Type type, object value)
|
||||
{
|
||||
{
|
||||
if (value is string str)
|
||||
value = str?.Replace("\t", "\\t")
|
||||
.Replace("\r\n", "\\r\\n")
|
||||
@ -43,9 +44,10 @@ namespace FreeSql.ClickHouse
|
||||
if (col.DbScale != 0) ret.Scale = col.DbScale;
|
||||
break;
|
||||
}
|
||||
//直接使用Bool
|
||||
//if (value is bool)
|
||||
// ret.Value = (bool)value ? 1 : 0;
|
||||
//if (value.GetType().IsArray)
|
||||
//{
|
||||
// ret.DbType = DbType.Object;
|
||||
//}
|
||||
}
|
||||
_params?.Add(ret);
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user