Skip to content

Listing materialized views with include_columns and limit drops columns #1113

Description

@hsusul

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions