supabase-js
supabase-js copied to clipboard
SDK returns incorrect value of `count` but `data` correctly filtered by `range()` and `is()`
Bug report
- [x] I confirm this is a bug with Supabase, not with my own application.
- [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
I tried to retrieve data from a table as follows.
I wanted to know the number of data filtered by range() and is().
However, the count value returns a value that ignores the range().
As a test, I set head to false and looked at the data in the return value, and it seems that the range filter is applied there (see the screenshot).
const input = req.params
const nullParams = input?.nullParams
let query = supabase
.from('docs')
.select('id', { count: 'exact', head: false })
.match({
user_id: user.id,
})
.order('created_at', { ascending: false })
if (nullParams && nullParams.length > 0) {
for (const nullParam of nullParams) {
// need to use .is() to filter data with null
query = query.is(nullParam, null)
}
}
if (input?.range) {
query = query.range(input.range.from, input.range.to)
}
return await query
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Go to '…'
- Click on '…'
- Scroll down to '…'
- See error
Expected behavior
The count value and the length of the data in the return value is the same.
Screenshots
System information
- OS: macOS
- Version of supabase-js: 2.39.3