@seancorfield any idea about this one?
(sql/format {:select [:tzdb.source :tzdb.uri [:cast :tzdb.tag_uuids [:raw "text[]"]]]})
;;=>
["SELECT tzdb.source, tzdb.uri, cast AS tzdb.tag_uuids"]
I want something like cast(tzdb.tag_uuids as text[])
This also doesn't work for me: (sql/format {:select [:tzdb.source :tzdb.uri [:raw "tzdb.tag_uuids::text[]"]]})
Again, this works: (sql/format {:select ['foo 'bar (symbol "tzdb.tag_uuids::text[]")]})
but it's pretty ugly :)
perhaps instead of (symbol "tzdb.tag_uuids::text[]")
honeysql could support a raw
function, since [:raw ...]
doesn't seem to work everywhere.
For functions in a select you need an extra level of brackets - otherwise it's an aliased column. The docs explain that but could clearly do a better job:grin:
:select [:tzdb.source :tzdb.uri [[:raw "tzdb.tag_uuids::text[]"]]]
there's nothing that can't be fixed using an extra pair of bracketsWell, :select [[:a :b]]
means SELECT a AS b
so :select [[[:foo :a] :b]]
means SELECT FOO(a) AS b
of course, once you see it you can't unsee it