fukamachi/sxql

Support for cast?

dan-passaro opened this issue · 2 comments

I have this sxql statement in one of my projects:

(sxql:select ((:sum :amount))
  (sxql:from :transaction)
  (sxql:where (:< (:raw "cast(amount as numeric)")
                  0)))

I tried a few different ways but I can't figure out how to eliminate the :RAW use in this snippet. Is it possible and I'm not able to figure it out?

How about this, though it's a little bit lengthy?

* (sxql:yield (sxql:where (:< (:cast (:as :amount :numeric)) 0)))
"WHERE (CAST(amount AS numeric) < ?)"
(0)

Awesome, this works perfectly! Thanks for your help, and for so many of your awesome CL libraries!