supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
2.86k stars 220 forks source link

Range Error: Invalid array length when I am using count exact and lte method #1030

Closed siamahnaf closed 2 weeks ago

siamahnaf commented 2 weeks ago
export const GET_SERVICES = async (client: SupabaseClient<Database>, value: PaginationInput) => {
    const limit = 2
    const { from, to } = getPagination(value.page, limit)
    const query = client.from("product").select("*, category!inner(*)", { count: "exact" }).range(from, to).gte("regular_price", value.price[0]).lte("regular_price", value.price[1]).order("created_at", { ascending: true });
    if (value.category) {
        query.eq("category.slug", value.category)
    }
    if (value.query) {
        query.ilike("title", `%${value.query}%`)
    }
    const { data, count } = await query;
    return {
        data: data,
        count: count,
        page: value.page,
        totalPage: Number(count) / limit
    }
}

Here I am using count "exact", and using lte method. But when this metthod value is 1400, it's giving me the "RangeError: Invalid array length". This is only occured when gte and lte value is 1400-1499 and I am suing count exact. It is not showing error If I remove the count exact.

Screenshot 2024-04-30 at 7 48 54 PM