Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当 IN 查询的条件为空数组时报错 #147

Closed
greensea opened this issue Jun 10, 2021 · 0 comments
Closed

当 IN 查询的条件为空数组时报错 #147

greensea opened this issue Jun 10, 2021 · 0 comments

Comments

@greensea
Copy link

下面的查询

bar := []int{}
.Where("foo", "in", bar).Get()

会报错:

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1

原因是这个查询生成的 SQL 语句是 ..... WHERE foo IN () ....
这样的语句在 MySQL 中是非法的。

希望在 in 查询传入空数组的时候,自动忽略这个 IN 条件

@fizzday fizzday closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants