Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • You say 'abuse' but I struggle to see in what way this is abuse ? The whole thing matches the Docs. (issue with removing values from an enum is an issue with just that, not an issue with your solution) Commented Oct 25, 2021 at 23:18
  • 1
    I agree that "abuse" is too strong of a word, this solution follows from the docs as you said. The only thing is that each time you do this, you are effectively taking a potentially large portion of the whole enum definition and counting over it. This could be a total non-issue or not depending on what the PostgreSQL query executor does, I haven't looked at the source code or performed benchmarks on this solution. Commented Nov 29, 2021 at 15:16
  • This is perfect. Moreover, I see no reason why the Postgres developers couldn't just make enumfield::int mean ARRAY_LENGTH(ENUM_RANGE(NULL, enumfield), 1) Commented Aug 11, 2025 at 13:31