Skip to content

[FreeSql.Provider.ClickHouse] Select.WithSql() => Syntax error: ('@') #1904

Open
@ktb-dev

Description

@ktb-dev

问题描述及重现代码:

var query = _freeSql.GetRepository<MyClass>().Select.WithSql(SqlQuery(), new Dictionary<string, object>
{
    { "@prop1", prop1 },
    { "@prop2", prop2 },
    { "@prop3", prop3 }
}).AsQueryable();

数据库版本

ClickHouse: 23.3.2.37

安装的Nuget包

"FreeSql.Provider.ClickHouse" Version="3.2.833"

.net framework/. net core? 及具体版本

net8.0

Error message:

Code: 62. DB::Exception: Syntax error: failed at position 785 ('@') (line 17, col 38): @Prop1
AND toDate(received) >= @Prop1
. Expected one of: CAST operator, ANY, ALL, NOT, INTERVAL, CASE, DATE, TIMESTAMP, tuple, collection of literals, array, number, literal, NULL, Bool, true, false, string literal, asterisk, qualified asterisk, compound identifier, list of elements, identifier, COLUMNS matcher, COLUMNS, qualified COLUMNS matcher, substitution, MySQL-style global variable. (SYNTAX_ERROR) (version 23.3.2.37 (official build))


To fix the bug, need to remove the "@" symbol from the parameter name:

DbParameter ret = new ClickHouseDbParameter { ParameterName = $"@{name}", Value = value };

DbParameter ret = new ClickHouseDbParameter { ParameterName = $"{name}", Value = value };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions