fix #372
This commit is contained in:
parent
718b7f036f
commit
dc37852024
3 changed files with 23 additions and 3 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
* 2.1.next in progress
|
||||||
|
* Fix #372 by merging `:select-distinct-on` differently.
|
||||||
|
* Update `build-clj` to v0.6.0.
|
||||||
|
|
||||||
* 2.1.829 -- 2021-11-27
|
* 2.1.829 -- 2021-11-27
|
||||||
* Fix #371 by treating the operand of `NOT` as a nested expression (so it is parenthesized unless it is a simple value).
|
* Fix #371 by treating the operand of `NOT` as a nested expression (so it is parenthesized unless it is a simple value).
|
||||||
* Fix #370 by **always** parenthesizing the operand of `:nest`.
|
* Fix #370 by **always** parenthesizing the operand of `:nest`.
|
||||||
|
|
|
||||||
2
deps.edn
2
deps.edn
|
|
@ -4,7 +4,7 @@
|
||||||
:aliases
|
:aliases
|
||||||
{;; for help: clojure -A:deps -T:build help/doc
|
{;; for help: clojure -A:deps -T:build help/doc
|
||||||
:build {:deps {io.github.seancorfield/build-clj
|
:build {:deps {io.github.seancorfield/build-clj
|
||||||
{:git/tag "v0.5.5" :git/sha "0527130"}}
|
{:git/tag "v0.6.0" :git/sha "2451bea"}}
|
||||||
:ns-default build}
|
:ns-default build}
|
||||||
|
|
||||||
;; versions to test against:
|
;; versions to test against:
|
||||||
|
|
|
||||||
|
|
@ -110,10 +110,20 @@
|
||||||
(simplify-logic))
|
(simplify-logic))
|
||||||
current)))
|
current)))
|
||||||
|
|
||||||
|
(defn- select-distinct-on-merge
|
||||||
|
"Since the first argument in a group is special, we
|
||||||
|
need to merge that, and then merge the other args."
|
||||||
|
[[c-on & current] [a-on & args]]
|
||||||
|
(-> (c/into (vec c-on) a-on)
|
||||||
|
(vector)
|
||||||
|
(c/into current)
|
||||||
|
(c/into args)))
|
||||||
|
|
||||||
(def ^:private special-merges
|
(def ^:private special-merges
|
||||||
"Identify the conjunction merge clauses."
|
"Identify the conjunction merge clauses."
|
||||||
{:where #'conjunction-merge
|
{:select-distinct-on #'select-distinct-on-merge
|
||||||
:having #'conjunction-merge})
|
:where #'conjunction-merge
|
||||||
|
:having #'conjunction-merge})
|
||||||
|
|
||||||
(defn- helper-merge [data k args]
|
(defn- helper-merge [data k args]
|
||||||
(if-let [merge-fn (special-merges k)]
|
(if-let [merge-fn (special-merges k)]
|
||||||
|
|
@ -400,6 +410,12 @@
|
||||||
[& args]
|
[& args]
|
||||||
(generic :select-distinct-on args))
|
(generic :select-distinct-on args))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(= (select-distinct-on [:a :b] :c [:d :dd])
|
||||||
|
(-> (select-distinct-on [:a] :c)
|
||||||
|
(select-distinct-on [:b] [:d :dd])))
|
||||||
|
)
|
||||||
|
|
||||||
(defn select-top
|
(defn select-top
|
||||||
"Accepts a TOP expression, followed by any number of
|
"Accepts a TOP expression, followed by any number of
|
||||||
column names, or column/alias pairs, or SQL expressions
|
column names, or column/alias pairs, or SQL expressions
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue