`public.packages` view should take `app.package_upgrades` into account as well for its latest_version column.

Open
#161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
postgresql, sql
Domain
databases

Research direction

Locate the definition of the public.packages view and inspect how app.package_versions and app.package_upgrades provide version values. Reproduce with my_ext--1.0.0.sql and my_ext--1.0.0--2.0.0.sql, then verify that latest_version reports 2.0.0 rather than 1.0.0.

Written by the indexing model from the issue text.

Description

bug

Currently the public.packages view is defined like this:

create or replace view public.packages as
    select
        pa.id,
        pa.package_name,
        pa.handle,
        pa.partial_name,
        newest_ver.version as latest_version,
        newest_ver.description_md,
        pa.control_description,
        pa.control_requires,
        pa.created_at,
        pa.default_version
    from
        app.packages pa,
        lateral (
            select *
            from app.package_versions pv
            where pv.package_id = pa.id
            order by pv.version_struct desc
            limit 1
        ) newest_ver;

Notice how in the lateral clause only app.package_versions are read but there's no app.package_upgrades. This results in the latest version being returned as less if there is one base version with an upgrade.

To reproduce publish an extension with my_ext--1.0.0.sql and my_ext--1.0.0--2.0.0.sql files and notice how the latest version reported is 1.0.0.

To fix, the view should take the maximum version from among the app.package_versions's version column and app.package_upgrade's to_version column.

Dominant language
TypeScript
Stars
443
Forks
31
Avg merge
1h 12m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from supabase/dbdev

All issues in supabase/dbdev

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.