Hi all, what do people use for scheduled background jobs when using Luminus?
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)))