Is anyone using postgres enums with honeySQL? So far the only way I found to make it work was to use either [:inline "enumValue"]
or (types/as-other "enumValue")
, in both cases the downside is that it involves modifying the query arguments, and keywords can't be used without an extra step to turn them into strings
yes that is what I have
(defn enum [k]
(types/as-other (name k)))
I wouldn't recommend the inline solution it's not the same, with as-other it's a ?
in your prepared statement, with inline
it's part of itI've added casts in the enum definition:
DO $$ BEGIN
CREATE TYPE idea_state AS ENUM ('draft', 'publish');
CREATE CAST (varchar AS idea_state) WITH INOUT AS ASSIGNMENT;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
But I was recently told that postgres enums are dangerous because you cannot add new values without dropping the enum, which is difficult to do when you already have data that point to the enum.
https://blog.yo1.dog/updating-enum-values-in-postgresql-the-safe-and-easy-way/ what you were told is not correct, adding is easy, updating is only since 9.6 and removing involves renaming / creating a new one / migrating
Could you write your own helper to handle the keyword conversion for you? e.g.
(defn clj-pg-enum
[kw]
[:inline (name kw)])