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

Limit 0 returns all row set instead of empty set #801

Open
KaitoHH opened this issue Mar 14, 2023 · 2 comments · May be fixed by #918
Open

Limit 0 returns all row set instead of empty set #801

KaitoHH opened this issue Mar 14, 2023 · 2 comments · May be fixed by #918

Comments

@KaitoHH
Copy link

KaitoHH commented Mar 14, 2023

The following lines

bun/query_select.go

Lines 634 to 637 in 7cd855e

if q.limit > 0 {
b = append(b, " LIMIT "...)
b = strconv.AppendInt(b, int64(q.limit), 10)
}

causes bun omits to append Limit 0 when selecting rows, resulting in returning all of the rows, which is not consistent with the expected empty set

@wikylyu
Copy link
Contributor

wikylyu commented Mar 28, 2023

I think limit 0 is meaningless. If you want to limit 0, why not just return [] without selecting database.

@KaitoHH
Copy link
Author

KaitoHH commented Apr 6, 2023

I think limit 0 is meaningless. If you want to limit 0, why not just return [] without selecting database.

I'm not to talk about whether it's meaningful to limit 0, but the correctness of the result. Since the result is not the same as what it is expected to return when using SQL, then that's the problem, isn't it?

OTOH, the following is quoted from MySQL docs regarding the usage of limit 0

LIMIT 0 quickly returns an empty set. This can be useful for checking the validity of a query. It can also be employed to obtain the types of the result columns within applications that use a MySQL API that makes result set metadata available.

@ygabuev ygabuev linked a pull request Oct 19, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants