我有一个 Postgres 枚举类型,用于描述源/目标关系表的节点类(顺序敏感)。问题是,如何动态获取枚举实例的下一个值(如果有)?
CREATE TYPE MyEnum AS ENUM ('level1', 'level2', 'level3');
SELECT dst_type, dst_id
FROM my_relationships
WHERE src_type::MyEnum = next(dst_type::MyEnum) -- does not work
-- WHERE src_type::MyEnum = dst_type::MyEnum + 1 -- does not work
AND src_id = 'd4fc1d5d-b054-d37c-4e80-2c04a6b3dbf8';