honeysql

Ngoc Khuat 2023-11-11T15:00:41.427019Z

šŸ‘‹ šŸ‘‹ 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;

Ngoc Khuat 2023-11-12T15:21:15.050519Z

That makes sense! thanks!

p-himik 2023-11-11T15:56:42.821999Z

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
seancorfield 2023-11-11T18:16:55.631499Z

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