tentative impl of VALUES statement in MySQL #544

Signed-off-by: Sean Corfield <sean@corfield.org>
This commit is contained in:
Sean Corfield 2024-09-28 14:47:15 -07:00
parent 48edb03b32
commit 3ca197b45c
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View file

@ -2,6 +2,7 @@
* 2.6.next in progress
* Performance optimizations via PRs [#545](https://github.com/seancorfield/honeysql/pull/545) and [#546](https://github.com/seancorfield/honeysql/pull/546) [@alexander-yakushev](https://github.com/alexander-yakushev).
* Address [#544](https://github.com/seancorfield/honeysql/issues/544) by adding support for MySQL's `VALUES ROW(..)` syntax. Docs TBD.
* Fix [#543](https://github.com/seancorfield/honeysql/issues/543) by supporting both symbols and keywords in named parameters.
* Address [#541](https://github.com/seancorfield/honeysql/issues/541) by specifying the expected result of a formatter function passed to `register-clause!` and adding the example from the README to **Extending HoneySQL**.
* Getting Started updated based on feedback from Los Angeles Clojure meetup walkthrough [#539](https://github.com/seancorfield/honeysql/issues/539).

View file

@ -1059,7 +1059,9 @@
")"))]))))
(defn- format-values [k xs]
(let [first-xs (when (sequential? xs) (first (drop-while ident? xs)))]
(let [first-xs (when (sequential? xs) (first (drop-while ident? xs)))
row-ctr (and (sequential? xs) (contains? #{:row 'rows} (first xs)))
xs (if row-ctr (rest xs) xs)]
(cond (and (ident? xs) (contains? #{:default 'default} xs))
[(str (sql-kw xs) " " (sql-kw k))]
(empty? xs)
@ -1087,7 +1089,8 @@
(map #(if (sequential? %)
(format-expr-list %)
[(sql-kw %)])
xs'))]
xs'))
sqls (if row-ctr (map #(str "ROW" %) sqls) sqls)]
(into [(str (sql-kw k) " " (join ", " sqls))] params))
(map? first-xs)
@ -2364,6 +2367,7 @@
(format-expr 1)
(format {:select [:a [:b :c] [[:d :e]] [[:f :g] :h]]})
(format {:select [[[:d :e]] :a [:b :c]]})
(format {:values [:row [1 2] [3 4]]})
(format-on-expr :where [:= :id 1])
(format-dsl {:select [:*] :from [:table] :where [:= :id 1]})
(format {:select [:t.*] :from [[:table :t]] :where [:= :id 1]} {})