Fixes #248 by changing how aliases are rendered
In theory, the only change here will be to stop the paren-wrapping in generation of alias SQL -- but I think that treating alias/columns pairs like this (as a nested alias) is very suspicious anyway so that probably ought to be fixed "properly" at some point.
This commit is contained in:
parent
f594235444
commit
94601ee5ae
3 changed files with 10 additions and 1 deletions
|
|
@ -1,3 +1,7 @@
|
||||||
|
## Changes coming in 0.9.7
|
||||||
|
|
||||||
|
* Fix #248 by treating alias as "not a subquery" when generating SQL for it. (@seancorfield)
|
||||||
|
|
||||||
## 0.9.6
|
## 0.9.6
|
||||||
|
|
||||||
* Filter `nil` conditions out of `where`/`merge-where`. Fix #246. (@seancorfield)
|
* Filter `nil` conditions out of `where`/`merge-where`. Fix #246. (@seancorfield)
|
||||||
|
|
|
||||||
|
|
@ -368,7 +368,8 @@
|
||||||
(if (= :select *clause*) " AS " " ")
|
(if (= :select *clause*) " AS " " ")
|
||||||
(if (or (string? alias) (keyword? alias) (symbol? alias))
|
(if (or (string? alias) (keyword? alias) (symbol? alias))
|
||||||
(quote-identifier alias :split false)
|
(quote-identifier alias :split false)
|
||||||
(to-sql alias)))))))
|
(binding [*subquery?* false]
|
||||||
|
(to-sql alias))))))))
|
||||||
|
|
||||||
(extend-protocol types/Inlinable
|
(extend-protocol types/Inlinable
|
||||||
#?(:clj clojure.lang.Keyword
|
#?(:clj clojure.lang.Keyword
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,10 @@
|
||||||
:quoting :mysql))
|
:quoting :mysql))
|
||||||
"aliases containing \".\" are quoted as necessary but not split"))
|
"aliases containing \".\" are quoted as necessary but not split"))
|
||||||
|
|
||||||
|
(deftest values-alias
|
||||||
|
(is (= ["SELECT vals.a FROM (VALUES (?, ?, ?)) vals (a, b, c)" 1 2 3]
|
||||||
|
(format {:select [:vals.a]
|
||||||
|
:from [[{:values [[1 2 3]]} [:vals {:columns [:a :b :c]}]]]}))))
|
||||||
(deftest test-cte
|
(deftest test-cte
|
||||||
(is (= (format-clause
|
(is (= (format-clause
|
||||||
(first {:with [[:query {:select [:foo] :from [:bar]}]]}) nil)
|
(first {:with [[:query {:select [:foo] :from [:bar]}]]}) nil)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue