Fix #226 by adding assert

This commit is contained in:
Sean Corfield 2018-09-02 18:35:02 -07:00
parent c25f8c73da
commit 284d0142b6
2 changed files with 11 additions and 8 deletions

View file

@ -2,6 +2,7 @@
* `#sql/inline nil` should produce `NULL`. Fix #221. (@seancorfield) * `#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). * `#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 ## 0.9.3

View file

@ -349,6 +349,8 @@
(paren-wrap (comma-join (map to-sql x))) (paren-wrap (comma-join (map to-sql x)))
:else :else
;; alias ;; alias
(do
(assert (= 2 (count x)) (str "Alias should have two parts" x))
(str (to-sql (first x)) (str (to-sql (first x))
; Omit AS in FROM, JOIN, etc. - Oracle doesn't allow it ; Omit AS in FROM, JOIN, etc. - Oracle doesn't allow it
(if (= :select *clause*) (if (= :select *clause*)
@ -356,7 +358,7 @@
" ") " ")
(if (string? (second x)) (if (string? (second x))
(quote-identifier (second x)) (quote-identifier (second x))
(to-sql (second x)))))) (to-sql (second x)))))))
(extend-protocol types/Inlinable (extend-protocol types/Inlinable
#?(:clj clojure.lang.Keyword #?(:clj clojure.lang.Keyword