From 23c652a02ee0a730c72f107c412dada870fe0f26 Mon Sep 17 00:00:00 2001 From: Hayden Date: Fri, 6 Oct 2023 13:29:06 +1030 Subject: [PATCH] Order defined enums by enumsortorder. Fixes #31 --- alembic_postgresql_enum/get_enum_data.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alembic_postgresql_enum/get_enum_data.py b/alembic_postgresql_enum/get_enum_data.py index 223ebf2..e211e25 100644 --- a/alembic_postgresql_enum/get_enum_data.py +++ b/alembic_postgresql_enum/get_enum_data.py @@ -68,7 +68,8 @@ def get_defined_enums(conn, schema: str) -> EnumNamesToValues: pg_catalog.format_type(t.oid, NULL), ARRAY(SELECT enumlabel FROM pg_catalog.pg_enum - WHERE enumtypid = t.oid) + WHERE enumtypid = t.oid + ORDER BY enumsortorder) FROM pg_catalog.pg_type t LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE