News for hackers. Stuff that matters.
Re:Representing Enums in PostgreSQL by wojcikstefan on Tuesday June 20, 2023 @10:48AM (#36404857)
Just to make sure I understand your suggestion fully, you're saying: 1. Use `smallint` instead of `text` for the column type. 2. Otherwise follow our "`CHECK` constraint" approach (without it we're jeopardizing data consistency because we can store anything between -32768 and 32767 in that column). 3. Translate the int to the enum in your application.

Right?

Re:Representing Enums in PostgreSQL by ComputerGuru on Tuesday June 20, 2023 @11:17AM (#36405229)
Most ORMs or just DALs can automate step 3 for you. If you’re using a strongly typed language with any type of ffi support, you’ll probably already have native cast from int to enum available (unless you’re using rust where that’s considered unsafe by default).
Re:Representing Enums in PostgreSQL by out_of_protocol on Tuesday June 20, 2023 @11:01AM (#36405073)
Yep!