Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subselect breaks after uberjar using composed queries #401

Open
Skiggz opened this issue Mar 19, 2019 · 0 comments
Open

Subselect breaks after uberjar using composed queries #401

Skiggz opened this issue Mar 19, 2019 · 0 comments

Comments

@Skiggz
Copy link

Skiggz commented Mar 19, 2019

I ran into issues where normal select functions were getting long (method too long!) so I started splitting them up to use predefined base queries (i.e. select*).

However, subselect gets messed up after uberjar (probably some issue with AOT or macro expansion but I couldn't dig enough to figure it out). I did find out what the issue is however, just not the cause. The SQL being generated changes from being wrapped in ticks to being wrapped in quotes ".

Long story short, this works:

(select :foo
        (fields
          [:foo.bar :title]
          [(subselect :bazz
                      (aggregate (avg :bazz.score) :avg_score)
                      (where (= :bazz.foo_id :foo.id))
                      (order :bazz.id :DESC)
                      (limit 10)) :rating])
        (where {:foo.age 10}))

This doesn't work:

;; create a base query to re use 
(def base (-> (select* :foo)
              (fields
                [:foo.bar :title]
                [(subselect :bazz
                            (aggregate (avg :bazz.score) :avg_score)
                            (where (= :bazz.foo_id :foo.id))
                            (order :bazz.id :DESC)
                            (limit 10)) :rating])))

;; query off the base query - works fine, until you uberjar, then subselect gets messed up
(select base
        (where {:foo.age 10}))

It's important to note, the latter does work during lein run but does not work after uberjar-ing and running the jar.

The SQL that gets messed up is in the subselect when broken is like so:

... (SELECT AVG("bazz"."score") AS "avg_score" ...

Which during lein run looks like this, and works as expected

... (SELECT AVG(`bazz`.`score`) AS `avg_score` ...

You'll notice the ticks replaced with quotes in the working and non working post jar. This is using version 0.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant