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 make get-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
/*~ ) ~*/
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.
hugsql
allows for the usage of clojure syntax within the queries, but when working with queries in therepl
an error is raised when runningrestart-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:Start repl
lein repl
Start app -
(start)
Migrate -
(migrate)
create at least 1 record
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:
Removing the lines of code from
get-user
and making it a simple query allowsrestart-db
to function properly. This has been verified on both linux mint and windows 10.