-
Cam Saul authored
* Fix some small things * Add Kondo to deps.edn to be able to debug custom hooks from REPL * Fix macroexpansion hook for with-temp* without values * Test config (WIP) * More misc fixes * Disable :inline-def for tests * More misc fixes * Fix $ids and mbql-query kondo hooks. * Fix with-temporary-setting-values with namespaced symbols * More misc fixes * Fix the rest of the easy ones * Fix hook for mt/dataset * Horrible hack to work around https://github.com/clj-kondo/clj-kondo/issues/1773 . Custom linter for mbql-query macro * Fix places calling mbql-query with a keyword table name * Fix the last few errors in test/ * Fix errors in enterprise/test and shared/test * Fix driver test errors * Enable linters on CI * Enable unresolved-namespace linter for tests * Appease the namespace linter again * Test fixes
Cam Saul authored* Fix some small things * Add Kondo to deps.edn to be able to debug custom hooks from REPL * Fix macroexpansion hook for with-temp* without values * Test config (WIP) * More misc fixes * Disable :inline-def for tests * More misc fixes * Fix $ids and mbql-query kondo hooks. * Fix with-temporary-setting-values with namespaced symbols * More misc fixes * Fix the rest of the easy ones * Fix hook for mt/dataset * Horrible hack to work around https://github.com/clj-kondo/clj-kondo/issues/1773 . Custom linter for mbql-query macro * Fix places calling mbql-query with a keyword table name * Fix the last few errors in test/ * Fix errors in enterprise/test and shared/test * Fix driver test errors * Enable linters on CI * Enable unresolved-namespace linter for tests * Appease the namespace linter again * Test fixes
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test.clj 1.01 KiB
(ns hooks.toucan.util.test
(:require [clj-kondo.hooks-api :as api]))
(defn- with-temp-inner [body bindings]
(let [binding-infos (for [[model {[binding value] :children}] (partition 2 bindings)]
{:model model
:binding binding
:value (or value
(api/token-node 'nil))})]
(-> (api/vector-node
[(api/vector-node (map :model binding-infos))
(-> (api/list-node (list* (api/token-node `let)
(api/vector-node (mapcat (juxt :binding :value) binding-infos))
body))
(with-meta (meta body)))])
(with-meta (meta body)))))
(defn with-temp [{:keys [node]}]
(let [[_ db-ref binding+opts & body] (:children node)]
{:node (with-temp-inner body [db-ref binding+opts])}))
(defn with-temp* [{:keys [node]}]
(let [[_ bindings & body] (:children node)]
{:node (with-temp-inner body (:children bindings))}))