Skip to content

Commit

Permalink
Fix #226 by adding assert
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Sep 3, 2018
1 parent c25f8c7 commit 284d014
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -2,6 +2,7 @@

* `#sql/inline nil` should produce `NULL`. Fix #221. (@seancorfield)
* `#sql/inline :kw` should produce `"kw"`. Fix #224 via PR #225. (@vincent-dm) Note: this introduces a new protocol, `Inlinable`, which controls inline value rendering, and changes the behavior of `#sql/inline :foo/bar` to produce just `"bar"` (where it was probably invalid SQL before).
* Alias expressions `[:col :alias]` are now checked to have exactly two elements. Fix #226.

## 0.9.3

Expand Down
18 changes: 10 additions & 8 deletions src/honeysql/format.cljc
Expand Up @@ -349,14 +349,16 @@
(paren-wrap (comma-join (map to-sql x)))
:else
;; alias
(str (to-sql (first x))
; Omit AS in FROM, JOIN, etc. - Oracle doesn't allow it
(if (= :select *clause*)
" AS "
" ")
(if (string? (second x))
(quote-identifier (second x))
(to-sql (second x))))))
(do
(assert (= 2 (count x)) (str "Alias should have two parts" x))
(str (to-sql (first x))
; Omit AS in FROM, JOIN, etc. - Oracle doesn't allow it
(if (= :select *clause*)
" AS "
" ")
(if (string? (second x))
(quote-identifier (second x))
(to-sql (second x)))))))

(extend-protocol types/Inlinable
#?(:clj clojure.lang.Keyword
Expand Down

0 comments on commit 284d014

Please sign in to comment.