esc
functionseq->update-vals
" return 'null's for nils(deftest should-sub-batch-upserts
(testing "should correctly sub params for values in batch upserts"
(let [q "insert into planets (\"id\", \"system\", \"planet\") values :planets"
sub (fn [q vs] (-> q (q/with-params {:planets {:as (q/seq->update-vals vs)}})))]
(is (= (str "insert into planets (\"id\", \"system\", \"planet\") "
"values "
"('42','solar','earth'),"
"('34',null,'saturn')," ;; <<<<<< before the null here would be ''
"('28','','pluto')")
(sub q [[42 "solar" "earth"]
[34 nil "saturn"]
[28 "" "pluto"]]))))))
(deftest should-sub-starts-with-params
(testing "should correctly sub params that start with the same prefix"
(let [q "select * from planets where moons = :super-position-moons and mass <= :super and name = :super-position"
sub (fn [q m] (-> q (q/with-params m)))]
(is (= "select * from planets where moons = 'up-and-down' and mass <= 42 and name = 'quettabit'"
(sub q {:super 42
:super-position "quettabit"
:super-position-moons "up-and-down"}))))))
Can you improve this documentation? These fine people already did:
anatoly, tolitius & AnatolyEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close