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

gdb: issue The SQL is wrong when using "WhereNotIn", if an empty parameter is passed #3619

Open
developer-r2tech opened this issue May 30, 2024 · 2 comments
Assignees

Comments

@developer-r2tech
Copy link

Go version

go version go1.21.9 linux/amd64

GoFrame version

2.7.1

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

var ids []int
dao.User.Ctx(ctx).WhereNotIn("id", ids).Count()

What did you see happen?

SELECT COUNT(1) FROM user WHERE 0=1

What did you expect to see?

SELECT COUNT(1) FROM user WHERE 1=1

@developer-r2tech developer-r2tech added the bug It is confirmed a bug, but don't worry, we'll handle it. label May 30, 2024
@developer-r2tech developer-r2tech changed the title orm: issue The SQL is wrong when using "WhereNotIn", if an empty parameter is passed gdb: issue The SQL is wrong when using "WhereNotIn", if an empty parameter is passed May 30, 2024
@niluan304
Copy link
Contributor

maybe better?

SELECT COUNT(1) FROM `user` WHERE NOT 0=1;

@gqcn gqcn self-assigned this Sep 23, 2024
@gqcn
Copy link
Member

gqcn commented Sep 23, 2024

@developer-r2tech It is designed as this, if condition parameters are empty for Where* function, ORM will use 0=1 condition to warn you the given condition is empty. It does not filter the empty condition automatically as it might lead unexpected business issue. More refer to https://goframe.org/pages/viewpage.action?pageId=7301832

@gqcn gqcn added question and removed bug It is confirmed a bug, but don't worry, we'll handle it. labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants