Fork me on GitHub
#honeysql
<
2022-04-26
>
jdf20:04:44

hi. is there a reason why a query like this

[{:select [[:stp.site_trial_id :site_trial_id] [#sql/call [:max :stp.created_at] :latest_activity_at]],
:from [[:SiteTrialPatientView :stp]],
:join [[:SiteTrialRead :st] [:= :st.id :stp.site_trial_id]],
:where [:and [:in :stp.site_trial_id #sql/param :site-trial-ids] [:<> :st.sponsor_trial_id nil] [:in :stp.stage [#object[org.postgresql.util.PGobject 0x3634ec9f "potential-candidate"] #object[org.postgresql.util.PGobject 0x73918461 "completed"] #object[org.postgresql.util.PGobject 0xb808f9e "enrolled"] #object[org.postgresql.util.PGobject 0x3ca4bc49 "pre-screen-failure"] #object[org.postgresql.util.PGobject 0x2de5ef56 "screen-failure"] #object[org.postgresql.util.PGobject 0x5228c407 "first-visit-scheduled"] #object[org.postgresql.util.PGobject 0x5d5b5da3 "in-screening"] #object[org.postgresql.util.PGobject 0x4484e4b5 "discontinued"] #object[org.postgresql.util.PGobject 0x46993c2c "pre-screening"]]]]}]
is returning the following error java.lang.AssertionError: Assert failed: Alias should have two parts . which alias is it referring to? the one in the select?

seancorfield20:04:31

That's HoneySQL 1.x?

seancorfield20:04:16

Is that the whole query (data structure)? There seems to be a [..`]` around the {:select ..} -- is that intentional?

jorda0mega20:04:08

Yeah that's the data structure returned from sql/format

jorda0mega20:04:13

Let me paste the original query

seancorfield22:04:15

sql/format should return a vector with a SQL string followed by the various parameters which that isn't... the hash map looks like what I'd expect you to pass in to sql/format but the vector around it seems odd.

jdf18:04:20

I ended up figuring out what it was (in case someone else runs into the same issue). I was defining a sql/param as such :where [:in (sql/param :site-trials)] where instead I just needed to pass the clojure seq :where [:in site-trials]

1