diff --git a/doc/clause-reference.md b/doc/clause-reference.md index 2eb464c..26a1b74 100644 --- a/doc/clause-reference.md +++ b/doc/clause-reference.md @@ -1305,6 +1305,21 @@ In addition, all of the rows are padded to the same length by adding `nil` values if needed (since `:values` does not know how or if column names are being used in this case). +### values row (MySQL) + +MySQL supports `VALUES` as a table expression in multiple +contexts, and it uses "row constructors" to represent the +rows of values. + +HoneySQL supports this by using the keyword `:row` (or +symbol `'row`) as the first element of a sequence of values. + + +```clojure +user=> (sql/format {:values [:row [1 2] [3 4]]}) +["VALUES ROW(?, ?), ROW(?, ?)" 1 2 3 4] +``` + ### values examples ```clojure diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 1ec5c0d..33fe09f 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -2370,6 +2370,10 @@ (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 {:with [[[:stuff {:columns [:id :name]}] + {:values [:row [1 "Sean"] [2 "Jay"]]}]] + :select [:id :name] + :from [:stuff]}) (format-on-expr :where [:= :id 1]) (format-dsl {:select [:*] :from [:table] :where [:= :id 1]}) (format {:select [:t.*] :from [[:table :t]] :where [:= :id 1]} {})