2 ms·
> Can you elaborate on what it means to use PostgreSQL enums "on your code API"? If you export a procedure for creating a socket into pgPlSQL, you shouldn't us
by marcosdumay 3y ago
> Can you elaborate on what it means to use PostgreSQL enums "on your code API"?
If you export a procedure for creating a socket into pgPlSQL, you shouldn't use magical numbers for setting the socket flags. You should use enums.
As for sqlalchmey, well that design is not good. It should support more mappings than just to string. But well, personally, I would ignore the feature and go without enum types (notice that it's a recent addition). You can always declare your own enum and convert the column if you want.
- faangsticle 3y ago> But well, personally, I would ignore the feature and go without enum types (notice that it's a recent addition). Postgres has had enums since 2008
- aidos 3y agoI still don't totally understand that first point. Are you talking about using enums for controlling the connection itself? Can you give an example? Just to clarify, sqlalchemy supports any arbitrary mapping you want — it's entirely flexible in every direction. EDIT ah, do you mean something like this? CREATE FUNCTION do_thing(flags custom_enum)
- marcosdumay 3y agoYep, you use it as CREATE FUNCTION do_something(some_option custom_enum). The main use-case is not putting them on tables. Relational algebra has the concept of enums builtin (as long as they all have the same structure). You create them in databases by using foreign keys.