user/restart-db fails when using hugsql clojure syntax
eskemojoe007 opened this issue · 0 comments
eskemojoe007 commented
hugsql
allows for the usage of clojure syntax within the queries, but when working with queries in the repl
an error is raised when running restart-db
when the code exists. The error does not happen if the repl is restarted.
Step to Recreate
lein new luminus myapp +postgres
- Create DB and update connection string in
dev-config.edn
- Modify
myapp/resources/sql/queries.sql
to makeget-user
to read:
-- :name get-user :? :1
-- :doc retrieves a user record given the id
SELECT * FROM users
/*~ (if (:id params) */
WHERE id = :id
/*~*/
where email = :email
/*~ ) ~*/
- Start repl
lein repl
- Start app -
(start)
- Migrate -
(migrate)
- create at least 1 record
(myapp.db.core/create-user!
{:id 1
:first_name "steve"
:last_name "jobs"
:email "steve.jobs@apple.com"
:pass "admin"})
- Test that both connection string types work:
(myapp.db.core/get-user {:id "1"})
(myapp.db.core/get-user {:email "steve.jobs@apple.com"})
(restart-db)
You get the following error:
class clojure.lang.Symbol cannot be cast to class clojure.lang.Namespace (clojure.lang.Symbol and clojure.lang.Namespace are in unnamed module of loader 'app')
Removing the lines of code from get-user
and making it a simple query allows restart-db
to function properly. This has been verified on both linux mint and windows 10.