Heyo, thanks for maintaining this library!
Is there support for postgres type hints ala 0::numeric
or ARRAY[1, 2, 3]::integer[]
? If not, do you have any suggestions for a way to add them?
I experimented with honeysql.core/raw
which of course would work, but that looses the data structure of any nested sql expressions.
raw
is the way to do this -- it accepts parameters in the most recent releases of HoneySQL so you shouldn't lose any structure.
HoneySQL has a guiding principle of being ANSI SQL compliant and delegating DB-specific syntax to other libraries (that choose to extend HoneySQL). There's a honeysql-postgres
library out there I think?
Thank you for your response! I will give it a go and reach back if that works for me. I didn’t see anything related to types in honeysql-postgres
but I’ll take another look.
you should be able to do that using something like (honeysql.core/call :cast 0 :numeric)
ah excellent! That I think will fit the bill
Thanks @jetmind -- I hadn't thought about adding an explicit cast
like that (I don't think I've ever needed a cast in my SQL code...?).
In my experience it sometimes come up when dealing with jsonb values in postgres
Ah, I don't use PostgreSQL -- and that does seem to where I see most of the questions about what looks to me like weird syntax and weird data types 🙂
HoneySQL even has a “cast” format handler! [:cast :0 :integer]
don't you need an #sql/call
reader tag before the vector for this to work?
oh, it does work automatically in the :where context, but not in the :select, for example