From 16e32901d5f8b4f42885f6af8f93dfcea507c873 Mon Sep 17 00:00:00 2001 From: 20521097 <20521097@qq.com> Date: Thu, 27 Oct 2022 16:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8Bsbyte=E5=AF=B9=E5=BA=94clickhouse=20Int8=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs | 4 ++++ .../ClickHouse/DbBind/ClickHouseDbBind.cs | 4 ++-- Src/Asp.NetCore2/SqlSugar/Enum/ProperyType.cs | 1 + .../SqlSugar/ExpressionsToSql/Common/SugarParameter.cs | 4 ++++ Src/Asp.NetCore2/SqlSugar/Utilities/UtilConstants.cs | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs index 18894a886..d5ff23d29 100644 --- a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/ClickHouseProvider.cs @@ -133,6 +133,10 @@ namespace SqlSugar.ClickHouse param.Value = Guid.Empty; } } + if (dbtype.ObjToString() == System.Data.DbType.SByte.ToString()) + { + dbtype = ClickHouseDbBind.MappingTypesConst.First(it => it.Value == CSharpDataType.@sbyte).Key; + } if (param.Value!=null&¶m.Value!=DBNull.Value&&dbtype.ObjToString() == System.Data.DbType.Boolean.ToString()) { sql = sql.Replace(param.ParameterName, param.Value.ObjToBool()?"1":"0"); diff --git a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs index f4c76747e..5ff879b3b 100644 --- a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs +++ b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs @@ -67,8 +67,8 @@ namespace SqlSugar.ClickHouse new KeyValuePair("UInt32",CSharpDataType.@int), new KeyValuePair("UInt16",CSharpDataType.@short), new KeyValuePair("UInt64",CSharpDataType.@long), - new KeyValuePair("Int8",CSharpDataType.@int), - new KeyValuePair("UInt8",CSharpDataType.@int), + new KeyValuePair("Int8",CSharpDataType.@sbyte), + new KeyValuePair("UInt8",CSharpDataType.@byte), new KeyValuePair("Decimal(38,19)",CSharpDataType.@decimal), new KeyValuePair("Decimal",CSharpDataType.@decimal), new KeyValuePair("Decimal32",CSharpDataType.@decimal), diff --git a/Src/Asp.NetCore2/SqlSugar/Enum/ProperyType.cs b/Src/Asp.NetCore2/SqlSugar/Enum/ProperyType.cs index 9ec673439..2ce145aec 100644 --- a/Src/Asp.NetCore2/SqlSugar/Enum/ProperyType.cs +++ b/Src/Asp.NetCore2/SqlSugar/Enum/ProperyType.cs @@ -15,6 +15,7 @@ namespace SqlSugar @double, @Guid, @byte, + @sbyte, @enum, @short, @long, diff --git a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs index c04b267b3..f0518e03d 100644 --- a/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs +++ b/Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/Common/SugarParameter.cs @@ -110,6 +110,10 @@ namespace SqlSugar { this.DbType = System.Data.DbType.Byte; } + else if (type == UtilConstants.SByteType) + { + this.DbType = System.Data.DbType.SByte; + } else if (type == UtilConstants.FloatType) { this.DbType = System.Data.DbType.Single; diff --git a/Src/Asp.NetCore2/SqlSugar/Utilities/UtilConstants.cs b/Src/Asp.NetCore2/SqlSugar/Utilities/UtilConstants.cs index 6387f7f01..5aee5dc5f 100644 --- a/Src/Asp.NetCore2/SqlSugar/Utilities/UtilConstants.cs +++ b/Src/Asp.NetCore2/SqlSugar/Utilities/UtilConstants.cs @@ -24,6 +24,7 @@ namespace SqlSugar internal static Type BoolType = typeof(bool); internal static Type BoolTypeNull = typeof(bool?); internal static Type ByteType = typeof(Byte); + internal static Type SByteType = typeof(sbyte); internal static Type ObjType = typeof(object); internal static Type DobType = typeof(double); internal static Type FloatType = typeof(float);