honeysql 2023-11-11

šŸ‘‹ šŸ‘‹ Could anyone please help me understand why this is an illegal syntax?

(honey.sql/format {:select [[:+ 1 1]]})
;; => illegal syntax in select expression
I’m expecting it to generate select 1 + 1;

That makes sense! thanks!

A scalar in :select means value/identifier. A 1-level vector means multiple values/identifiers. A 2-level vector means the same, but with aliases. A 3-level vector means the same, but with function calls. So you need a 3-level vector. And by "3-level" I mean "nested 3 levels deep", so [[[:+ 1 1]]] should work.

šŸ‘€ 1
šŸ™ 1

@qn.khuat Take a look at the SQL Expressions section early in Getting Started https://cljdoc.org/d/com.github.seancorfield/honeysql/2.5.1091/doc/getting-started -- it has examples of :select with those 3 levels of vectors.