Describe the bug
GET /materialized-views?include_columns=true&limit=N applies limit/offset to the columns CTE as well as to the materialized views themselves. Tables, views, and foreign tables do not do this.
The columns query is not scoped to the selected matviews, so the global LIMIT can pick a column from an unrelated relation. The listed matview then comes back with a truncated or empty columns array.
To Reproduce
Using the todos_matview fixture (three columns):
GET /materialized-views?include_columns=true&limit=1
Expected behavior
One materialized view is returned, with all three columns (id, details, user-id), matching GET /materialized-views?include_columns=true without limit.
Actual behavior
The matview is returned with columns: [] (or fewer columns than it has), because COLUMNS_SQL ran with LIMIT 1 across every relation.
Additional context
generateEnrichedMaterializedViewsSql forwards limit/offset into COLUMNS_SQL. generateEnrichedViewsSql / generateEnrichedTablesSql / generateEnrichedForeignTablesSql only paginate the relation CTE.
- Library:
@supabase/postgres-meta
- Branch analyzed:
master (641831e)
Describe the bug
GET /materialized-views?include_columns=true&limit=Napplieslimit/offsetto the columns CTE as well as to the materialized views themselves. Tables, views, and foreign tables do not do this.The columns query is not scoped to the selected matviews, so the global
LIMITcan pick a column from an unrelated relation. The listed matview then comes back with a truncated or emptycolumnsarray.To Reproduce
Using the
todos_matviewfixture (three columns):Expected behavior
One materialized view is returned, with all three columns (
id,details,user-id), matchingGET /materialized-views?include_columns=truewithoutlimit.Actual behavior
The matview is returned with
columns: [](or fewer columns than it has), becauseCOLUMNS_SQLran withLIMIT 1across every relation.Additional context
generateEnrichedMaterializedViewsSqlforwardslimit/offsetintoCOLUMNS_SQL.generateEnrichedViewsSql/generateEnrichedTablesSql/generateEnrichedForeignTablesSqlonly paginate the relation CTE.@supabase/postgres-metamaster(641831e)