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

SDK returns incorrect value of count but data correctly filtered by range() and is() #1275

Open
2 tasks done
taishikato opened this issue Oct 1, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@taishikato
Copy link

taishikato commented Oct 1, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • 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:

  1. Go to '…'
  2. Click on '…'
  3. Scroll down to '…'
  4. See error

Expected behavior

The count value and the length of the data in the return value is the same.

Screenshots

CleanShot 2024-10-01 at 16 00 37@2x

System information

  • OS: macOS
  • Version of supabase-js: 2.39.3
@taishikato taishikato added the bug Something isn't working label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant