Skip to content

Commit

Permalink
document values row (docs also test)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Corfield <sean@corfield.org>
  • Loading branch information
seancorfield committed Sep 29, 2024
1 parent 7c0e25f commit a27f72e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doc/clause-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/honey/sql.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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]} {})
Expand Down

0 comments on commit a27f72e

Please sign in to comment.