Open ktb-dev opened 3 weeks ago
ToLower
ToLower
ah, no. My parameter name is written with a lowercase letter, everywhere it appears in the code.
The thing is that the github editor read @prop1 as a nickname, and that's why my error message showed the name 'prop1' with an uppercase letter.
{ { "prop1", prop1 }, { "prop2", prop2 }, { "prop3", prop3 } }
My clickhouse server is not available here, but I tested the code using SQL Server and it worked fine.
var result1 = fsql.Select<object>().WithSql("select @Prop1 as1", new { Prop1 = 1 }).ToList();
var result2 = fsql.Select<object>().WithSql("select @Prop1 as1", new Dictionary<string, object> { { "Prop1", 1 } }).ToList();
var result1 = fsql.Select<object>().WithSql("select @Prop1 as1", new { Prop1 = 1 }).ToList(); var result2 = fsql.Select<object>().WithSql("select @Prop1 as1", new Dictionary<string, object> { { "Prop1", 1 } }).ToList();
debug screenshot with an exception
FreeSql config:
builder.Services.AddSingleton((provider) =>
{
var connectionString = GetConnectionString(provider);
return new FreeSqlBuilder()
.UseConnectionString(DataType.ClickHouse, connectionString)
.Build();
}) ;
An exception was also thrown here:
var result3 = await _freeSql.Ado.QueryAsync<object>("select @Prop1 as1, @prop2 as2", new { Prop1 = 1, prop2 = 2 });
But with such a select, everything was successful:
ClickHouseDbParameter[] dbParams = [
DbParameter("Prop1", 1),
DbParameter("prop2", 2)
];
var result4 = await _freeSql.Ado.QueryAsync<object>(System.Data.CommandType.Text, "select @Prop1 as1, @prop2 as2", dbParams);
@2881099, doesn't that seem strange to you?
but I tested the code using SQL Server and it worked fine.
the issue arises precisely when executing a select with parameters via the clickhouse client
问题描述及重现代码:
数据库版本
ClickHouse: 23.3.2.37
安装的Nuget包
"FreeSql.Provider.ClickHouse" Version="3.2.833"
.net framework/. net core? 及具体版本
net8.0
Error message:
To fix the bug, need to remove the "@" symbol from the parameter name:
https://github.com/dotnetcore/FreeSql/blob/a7ddaff4707e9cd5a8e30789b51a6187f87baeaa/Providers/FreeSql.Provider.ClickHouse/ClickHouseUtils.cs#L66