sql

All things SQL and JDBC...
kwladyka 2020-03-10T08:59:59.153900Z

@seancorfield as far as I understand binding and with-redefs it should work for with-redefs even more, because it works also for Thread

kwladyka 2020-03-10T09:00:13.154200Z

unless there is something what I don’t know about Clojure

kwladyka 2020-03-10T09:06:46.154700Z

#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 original

kwladyka 2020-03-10T09:09:03.155Z

the value is also replaced in inner function which I call

kwladyka 2020-03-10T09:09:20.155300Z

(defn create-shop [shop]
  (println postgres/db)
  (postgres/insert! :shops shop))

kwladyka 2020-03-10T09:09:25.155500Z

strange

kwladyka 2020-03-10T09:11:00.155800Z

but not here

(def insert! (partial sql/insert! (or (println "!!!" db) db))

kwladyka 2020-03-10T09:11:30.156300Z

it doesn’t replace db only in final function

kwladyka 2020-03-10T09:13:54.156700Z

(defn insert! [& args]
  (println "!!!!!!" db)
  (apply sql/insert! db args))
but it works with defn

kwladyka 2020-03-10T09:14:05.156900Z

ok I don’t understand this

kwladyka 2020-03-10T09:15:23.157100Z

(def a 1)

(with-redefs [a 2]
  (println a))
this shows 2

kwladyka 2020-03-10T09:17:59.157400Z

(def a 1)
(def b (partial println "!" a "!"))

(with-redefs [a 2]
  (b a))
this print ! 1 ! 2

kwladyka 2020-03-10T09:18:18.157800Z

so it looks like with-redefs doesn’t work with partial?

kwladyka 2020-03-10T09:20:50.158600Z

binding doing the same

kwladyka 2020-03-10T09:20:55.158800Z

this is the partial issue

kwladyka 2020-03-10T09:21:15.159300Z

it looks like it get value of def and doesn’t refer to this def anymore

kwladyka 2020-03-10T10:04:27.159600Z

oh I know why… I solved this on #clojure

souenzzo 2020-03-10T13:35:16.161100Z

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

👍 1