This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-08
Channels
- # 100-days-of-code (1)
- # admin-announcements (1)
- # aleph (1)
- # announcements (9)
- # beginners (125)
- # cider (1)
- # cljs-dev (80)
- # cljsrn (2)
- # clojure (82)
- # clojure-czech (1)
- # clojure-dev (5)
- # clojure-finland (1)
- # clojure-italy (16)
- # clojure-nl (6)
- # clojure-spec (24)
- # clojure-uk (39)
- # clojurescript (35)
- # community-development (49)
- # core-async (3)
- # cursive (31)
- # data-science (17)
- # datomic (21)
- # emacs (5)
- # fulcro (92)
- # graphql (1)
- # jobs (2)
- # lambdaisland (1)
- # leiningen (19)
- # luminus (9)
- # off-topic (21)
- # parinfer (6)
- # pedestal (1)
- # portkey (2)
- # re-frame (12)
- # reagent (8)
- # reitit (4)
- # shadow-cljs (117)
- # spacemacs (5)
- # specter (4)
- # sql (2)
- # testing (2)
- # tools-deps (3)
- # vim (1)
Howzit everyone, I have a very peculiar issue that I just managed to reproduce successfully on a test project. It’s related to conman/hugsql (and postgres)
if I use clojure expressions in queries.sql
, I can’t use (restart-db)
in the user
namespace anymore, it dies with:
user=> (restart-db)
java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace
clojure.lang.Compiler$CompilerException: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Namespace, compiling:(null:1:1)
switching to the .db.core
ns and then binding the connection works just fine
user=> (in-ns 'lumipg.db.core)
#namespace[lumipg.db.core]
lumipg.db.core=> (conman/bind-connection *db* "sql/queries.sql")
{:fns {:clj-expr-single {:fn #<Fn@502dc1a8 conman.core/try_query[fn/fn]>
:meta {:command :?
:doc ""
:file "sql/queries.sql"
:line 1
:result :1}}}
:snips {}}
and the query is an example straight from the Hugsql docs, so nothing special:
-- :name clj-expr-single :? :1
select
--~ (if (seq (:cols params)) ":i*:cols" "*")
from test
order by id
but somehow rebinding *ns*
is not doing the trick, and I don’t know where to report the issue. is this a problem with conman or the way the template sets up the restart-db
function?
sample project is a straight forward lein new luminus lumipg +postgres
with 3.10.11
I’m stumped, I spent a bit of time just stepping through the execution in IntelliJ and alas I’m none the wiser
settled for this inside (restart-db)
and seems to work (so far 🤞)
(try
(in-ns 'lumipg.db.core)
(conman/bind-connection lumipg.db.core/*db* "sql/queries.sql")
(finally
(in-ns 'user)))