hugsql

curtis.summers 2022-04-14T12:17:52.202049Z

Yes, this is still not working (even with depstar as in the original issue). I've updated that bug, and will try to get a fix out in the next few days. I'll probably switch back to macros.

seancorfield 2022-04-14T21:05:39.068619Z

It's a tricky one -- and macros vs functions is irrelevant I think since the issue is about invocation at load time which happens for both compilation and for running in a standalone JAR.

JB Seo 2022-04-14T01:31:24.031419Z

Hello, I have a question on the latest release v0.5.2. • fix fn defs to be at compile-time https://github.com/layerware/hugsql/issues/126 (thanks https://github.com/kelvinqian00https://github.com/kelvinqian00)!) Does it work well with leiningen? With leinignen, uberjar with option 'aot all & omit-source' still throws 'Can not read file' exception. Test project: https://github.com/jngbng/hugsql_aot

JB Seo 2022-04-14T01:37:07.148339Z

Honestly, I don't understand why switching 'def-db-fns' from macro to a normal function would prevent executing it on runtime (so that it will not read SQL file on start up.)

seancorfield 2022-04-14T02:07:14.168679Z

@jbseo The assumption is that you are calling (def-db-fns) as a top-level form in your namespace so when you load the ns (for compilation) it runs and loads the SQL and defines all the functions. If you're calling (def-db-fns) anywhere, it's not going to work.

JB Seo 2022-04-14T02:08:36.774279Z

Yes, I did call it on top-level from in my namespace: https://github.com/jngbng/hugsql_aot/blob/master/src/hugsql_aot/db.clj

seancorfield 2022-04-14T02:07:25.608819Z

(at least, that's my reading of the changes made in 0.5.2)

JB Seo 2022-04-14T02:13:42.601099Z

With the following file:

(ns hello.echo)

(prn "I am hello.echo")
I will see the greeting message both on AOT compilation time and on starting the program. Am I right?

seancorfield 2022-04-14T02:17:25.489109Z

I'm just guessing at their intent: I'm not saying it actually works if the source is not present in the JAR file 🙂 I don't know how well it has been tested...

JB Seo 2022-04-14T02:18:13.701839Z

I see, Thanks!

seancorfield 2022-04-14T02:20:45.363859Z

In #126, the OP says "Indeed it does work! (Plus the conversion from using macros to regular functions cleans up the core code.)" so the solution worked for their use case...

seancorfield 2022-04-14T02:21:20.590149Z

(that convo suggests it does work for them since they are excluding .sql files from their JAR...)

JB Seo 2022-04-14T02:24:40.868779Z

Yes, so I wonder how it could be possible. With the definition of https://github.com/layerware/hugsql/blob/ad73d080f84487c3438058ed5203d44f06c46365/hugsql-core/src/hugsql/core.clj#L530, I think it should read SQL file on start up time.

seancorfield 2022-04-14T02:29:11.947659Z

I just tried it with your repro project and even with a few tweaks and edits, I cannot get it to work "as advertised" so it definitely "doesn't work" as I would expect.

seancorfield 2022-04-14T02:29:57.303749Z

You could create a new issue and link back to #126 and your repo.