Fork me on GitHub
#honeysql
<
2023-11-11
>
Ngoc Khuat15:11:41

👋 👋 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;

p-himik15:11:42

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
seancorfield18:11:55

@U023C0QKU4W 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.

Ngoc Khuat15:11:15

That makes sense! thanks!