what’s the proper way to use a pg enum? i see #224 and others related but don’t see the conclusion
my current path forward is this, but obviously not ideal
(sql/raw (str "'" (name :keyword-i-use) "'"))
Why not just (name :keyword-i-use)
as a parameter @benny? Why try to make it into a raw SQL string?
afaik i’m using pg and that imposes double quotes which references a column
(and then read https://cljdoc.org/d/seancorfield/next.jdbc/1.1.582/doc/getting-started/tips-tricks#working-with-enumerated-types for how to have the conversion handled by next.jdbc
)
I don't understand you.
(name :keyword-i-use)
is a string and will be treated just like any other string (parameter).
right, sorry
that was a different approach i tried
but using (name
passes it as a parameter
which implied character varying
instead of enum
It will probably help people help you if you can share actual code then instead of talking about abstractions 🙂
Did you read the link I posted in the main channel?
i did, that’s what i’ll use
it mimics what i’m doing it looks
It explains how to have those string parameters treated as enums.
It is not like what you're doing.
but to clarify:
(sql/format {:select [:*] :from [:foo] :where [:= :status (name :pending)]})
=> ["SELECT * FROM foo WHERE status = ?" "pending"]
that is invalid for an enum column
Read the link I posted. It says how to make that work.
agreed, just clarifying why just using (name :foo)
wouldn’t suffice
it passes it as a parm
Right, which is what you want.
i don’t want a param
pg sees it as a character varying value
if it’s passed as a param
it has to be inline
No it doesn't.
That link I posted shows how to handle this situation.
It is specifically about enumerated types in PostgreSQL.
(as-other (name :pending))
or even just (as-other "pending")
agreed
as-other
is needed
Which is why I posted that link 🙂
that’s all i’m saying, it can’t just be name
it has to be name + your or my wrapper
But it can be a parameter, which was what I was telling you.
it can’t 🙂
well with yours it can
but just as name it can’t
i think we’re in violent agreement
just don’t want someone to fall into the trap that just name
will work, you need more like as-other
If anyone actually reads the PostgreSQL-specific docs in next.jdbc
, they would know that.
practically i don’t think many people read them all the way through and a bunch of google’s only lead me to 224
My two messages were basically "Don't do that awful raw
thing -- use plain ol' (name :keyword-i-use)
and then do what it tells you in the docs."
i blame google’s indexing 😉
I blame people for not actually reading the docs 🙂
i guess the same could be said about eulas lol
lots of important things in there that people glaze over too
i agree though, i should’ve read it
and thank you for spending your time pointing me in the right direction
your stuff is above par
Thanks. When I rewrite HoneySQL, I intend it to have docs on par with next.jdbc
.