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

Issue: 'content-range' from response header with aggregation function #3800

Open
jeffoo713 opened this issue Nov 21, 2024 · 1 comment
Open
Labels
aggregates Related to aggregate functionality

Comments

@jeffoo713
Copy link

Environment

  • PostgreSQL version: v14.12
  • PostgREST version: v12.2.3
  • Operating system: MacOS

Description of issue

Hi there, I'd like to report some buggy 'content-range' value in the response header with aggregation function.

  • Minimal SQL definition
CREATE TABLE employees (
    id SERIAL PRIMARY KEY,
    organization_id INTEGER,
    first_name VARCHAR,
    last_name VARCHAR,
    gender VARCHAR,
    status VARCHAR
);
  • How I make a request to Postgrest:
    http:<postgrest_url>/employees?limit=100&offset=0&and=(or(status.like.active))&select=count(),gender
  • The behaviour I expect:
    In the response header, "content-range" value should be '0-2/3'. There are only 3 gender values in DB: male, female, undisclosed.
  • The actual behaviour:
    In the response header, "content-range" value is '0-2/147'.
    I suspect the total number of record "147" is from the total number of records without aggregation.
    When I make a request without aggregation; http:<postgrest_url>/employees?limit=100&offset=0&and=(or(status.like.active)) I have '0-99/147' as "content-range" value in the response header.

Thank you in advance!

@jeffoo713 jeffoo713 changed the title Issue: 'content-range' from response header buggy with aggregation function Issue: 'content-range' from response header with aggregation function Nov 21, 2024
@scott-8
Copy link

scott-8 commented Mar 9, 2025

Also seeing this issue, where "content-range" displays the total number of rows in the table rather than the number of rows after the aggregation.

For example, making this query to a table that has 100 rows with 5 unique values of name:

http://localhost:3000/table_name?selet=count(),name

returns 0-5/100 as content-range, while it should be returning 5.

@steve-chavez steve-chavez added the aggregates Related to aggregate functionality label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aggregates Related to aggregate functionality
Development

No branches or pull requests

4 participants