Skip to content

Comments

[Postgres] Order ENUM values#61133

Merged
nyalldawson merged 1 commit intoqgis:masterfrom
jmonticolo:feat_ordered_pg_enums
Mar 23, 2025
Merged

[Postgres] Order ENUM values#61133
nyalldawson merged 1 commit intoqgis:masterfrom
jmonticolo:feat_ordered_pg_enums

Conversation

@jmonticolo
Copy link
Contributor

Description

When a vector layer with Postgres / PostGIS provider with an ENUM type field is edited, the values are loaded with the following query :

SELECT enumlabel
FROM pg_catalog.pg_enum
WHERE
    enumtypid = (
        SELECT atttypid::regclass
        FROM pg_attribute
        WHERE
            attrelid = '"table_schema"."table_name"'::regclass
            AND attname='field_name'
    )
;

In the great majority of cases, the ENUM values are read in the right order, but not always.
This PR adds ORDER BY enumsortorder at the end of the query.

Impact : the request is slightly longer (the quicksort adds few milliseconds).

@github-actions github-actions bot added this to the 3.44.0 milestone Mar 21, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 8260527)

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 8260527)

@nyalldawson nyalldawson merged commit 2ebb99d into qgis:master Mar 23, 2025
36 checks passed
@jmonticolo jmonticolo deleted the feat_ordered_pg_enums branch March 24, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants