dotnetcore / dotnetcore/FreeSql

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

Open
#1,904 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

#### 问题描述及重现代码:

```c#
var query = _freeSql.GetRepository().Select.WithSql(SqlQuery(), new Dictionary
{
{ "@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:

https://github.com/dotnetcore/FreeSql/blob/a7ddaff4707e9cd5a8e30789b51a6187f87baeaa/Providers/FreeSql.Provider.ClickHouse/ClickHouseUtils.cs#L66

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.