@seancorfield as far as I understand binding
and with-redefs
it should work for with-redefs
even more, because it works also for Thread
unless there is something what I don’t know about Clojure
#object[org.postgresql.jdbc.PgConnection 0x5f7b586a org.postgresql.jdbc.PgConnection@5f7b586a]
(with-redefs [db-psql/db tx]
(println db-psql/db)
(tests))
this even show different value for db
than originalthe value is also replaced in inner function which I call
(defn create-shop [shop]
(println postgres/db)
(postgres/insert! :shops shop))
strange
but not here
(def insert! (partial sql/insert! (or (println "!!!" db) db))
it doesn’t replace db
only in final function
(defn insert! [& args]
(println "!!!!!!" db)
(apply sql/insert! db args))
but it works with defn
ok I don’t understand this
(def a 1)
(with-redefs [a 2]
(println a))
this shows 2
(def a 1)
(def b (partial println "!" a "!"))
(with-redefs [a 2]
(b a))
this print ! 1 ! 2
so it looks like with-redefs
doesn’t work with partial
?
binding
doing the same
this is the partial
issue
it looks like it get value of def
and doesn’t refer to this def
anymore
oh I know why… I solved this on #clojure
About qualified/unqualified keys, checkout https://github.com/souenzzo/eql-as I'm using it on every project that I work It solves both qualified->unqualified and un->qualified