does anyone have example of WITH
expression?
There’s no documentation, and I can’t find out why it produces invalid query
(-> (helpers/with [(-> (helpers/select :upc.amount :upc.id :pc.expires_at)
(helpers/from [:user_promo_codes :upc])
(helpers/join [:promo_codes :pc] [:= :pc.code :upc.promo_code_id])
(helpers/where [:and
[:> :pc.expires_at (time/now)]
[:= :upc.user_id user_id]]))
"not_expired"])
(helpers/select :*)
(helpers/from :not_expired)
(helpers/where [:= :not_expired.amount (-> (helpers/select (sql/call :max :bar.amount))
(helpers/from :not_expired))])
(sql/format)
((fn [p] (prn p) p))
(->> (db/execute <db>)))
hmm, false alarm, seems like trouble is not with WITH expression
hmm, not false alarm slightly_smiling_face made it finally