Is there a way to reference a quoted alias without :raw?
I want to use quoted alias in ORDER BY clause
SELECT column_name AS "some-alias" FROM b ORDER BY "some-alias" ASC
I would like to avoid using :raw because the alias value comes from 3d party
(honey.sql/format {:select [[:column-name "some-alias"]]
:from :b
:order-by [[[:raw "\"some-alias\""]]]})
Quoting everything doesn't work because it doesn't convert kebab column names to underscores
(honey.sql/format {:select [[:column-name "some-alias"]]
:from :b
:order-by [:some-alias]}
{:quoted true})
SELECT "column-name" AS "some-alias" FROM "b" ORDER BY "some-alias" ASC
And quoted-snake corrupts dashes in aliases
(honey.sql/format {:select [[:column-name "some-alias"]]
:from :b
:order-by [:some-alias]}
{:quoted-snake true})
SELECT column_name AS "some_alias" FROM b ORDER BY some_alias ASCOh, huh. There's stuff like :'x but apparently it works only when it's in a function-calling context.
thank you for the :'x didn't know it exists, it can cover some cases
@nbardiuk Feel free to create an issue on GitHub for me to look at. AS aliases have special treatment so maybe I'll need to add special syntax like [:alias "some-alias"] so you can get that treatment elsewhere...
@seancorfield Wouldn't it make more sense to support :'x everywhere? A breaking change, I suppose, but maybe could be put behind an opt-in flag?
That's something I'll take a look at as part of this issue.
I think the behavior of :'x may already be context-dependent but I'd have to refresh my memory...