This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-19
Channels
- # aleph (1)
- # announcements (3)
- # aws (1)
- # beginners (95)
- # calva (15)
- # clojars (4)
- # clojure (84)
- # clojure-android (3)
- # clojure-austin (1)
- # clojure-chicago (1)
- # clojure-dev (66)
- # clojure-europe (3)
- # clojure-italy (15)
- # clojure-nl (13)
- # clojure-uk (33)
- # clojuredesign-podcast (9)
- # clojurescript (6)
- # cursive (68)
- # data-science (4)
- # datavis (1)
- # datomic (13)
- # emacs (4)
- # fulcro (2)
- # jobs (4)
- # jobs-discuss (89)
- # luminus (23)
- # nrepl (6)
- # off-topic (2)
- # onyx (2)
- # pathom (4)
- # pedestal (11)
- # re-frame (9)
- # reagent (8)
- # reitit (5)
- # shadow-cljs (131)
- # spacemacs (13)
- # sql (8)
- # vim (8)
- # xtdb (7)
- # yada (4)
Could Emacs + CIDER + next.jdbc + org-mode + some code make a great universal SQL client, something like TRAMP but for databases ?

what is the nice way to pass a java.time.Period
/`java.time.Duration` into a hugsql query and use it as a Postgres interval?
left to my own devices I would write a Clojure function that converts java.time.Period
into org.postgresql.util.PGInterval
but open to better suggestions...
something crude-yet-efffective like
(defn period->pginterval
[^java.time.Period p]
(doto (org.postgresql.util.PGInterval.)
(.setYears (.getYears p))
(.setMonths (.getMonths p))
(.setDays (.getDays p))))
er so I ended up with
(ns postgres-intervalable)
(defn period->pginterval
[^java.time.Period p]
(doto (org.postgresql.util.PGInterval.)
(.setYears (.getYears p))
(.setMonths (.getMonths p))
(.setDays (.getDays p))))
(defn duration->pginterval
[^java.time.Duration d]
(doto (org.postgresql.util.PGInterval.)
(.setSeconds (.getSeconds d))))
(defprotocol PGIntervalable
(to-pginterval [d]
"converts data to equivalent org.postgresql.util.PGInterval instance"))
(extend-protocol PGIntervalable
java.time.Period
(to-pginterval [p] (period->pginterval p))
java.time.Duration
(to-pginterval [d] (duration->pginterval d)))
feels like reinvention though...
(map postgres-intervalable/to-pginterval
[(java-time/period "P1Y")
(java-time/period "P1M")
(java-time/period "P1D")
(java-time/duration "PT24H")
(java-time/duration "PT24M")
(java-time/duration "PT24S")
])
=>
(#object[org.postgresql.util.PGInterval
0x33754f2a
"1 years 0 mons 0 days 0 hours 0 mins 0.00 secs"]
#object[org.postgresql.util.PGInterval
0x608f2210
"0 years 1 mons 0 days 0 hours 0 mins 0.00 secs"]
#object[org.postgresql.util.PGInterval
0x6be3b450
"0 years 0 mons 1 days 0 hours 0 mins 0.00 secs"]
#object[org.postgresql.util.PGInterval
0x90622fb
"0 years 0 mons 0 days 0 hours 0 mins 86400.00 secs"]
#object[org.postgresql.util.PGInterval
0x101320ee
"0 years 0 mons 0 days 0 hours 0 mins 1440.00 secs"]
#object[org.postgresql.util.PGInterval
0x9150f5e
"0 years 0 mons 0 days 0 hours 0 mins 24.00 secs"])
This feels like something you'd use SettableParameter
for in next.jdbc
...
not an option for me at the moment sadly