r0man / sqlingvo

A Clojure & ClojureScript DSL for SQL
Eclipse Public License 1.0
210 stars 23 forks source link

How do I pass arguments to SQL functions? #113

Open asultanpur opened 6 years ago

asultanpur commented 6 years ago

I want to pass the value of a var to my SQL function.

(sql/sql (sql/select db [:*] (sql/from `(:my-func ~arg))))

But I get an error:

ExceptionInfo Can't parse FROM form.  clojure.core/ex-info (core.clj:4739)

However I'm able to pass string arguments:

=> (sql/sql (sql/select db [:*] (sql/from '(:my-func "abc"))))
["SELECT * FROM \"my_func\"(?)" "abc"]

I want to pass the value of arg instead of plain string. How do I do that?

r0man commented 6 years ago

It might be that a function in the from clause is not yet supported. I am AWFK at the moment. PR welcome!

On Tue, Jun 26, 2018, 16:03 Avinash Sultanpur notifications@github.com wrote:

I want to pass the value of a var to my SQL function.

(sql/sql (sql/select db [:*] (sql/from `(:my-func ~arg))))

But I get an error:

ExceptionInfo Can't parse FROM form. clojure.core/ex-info (core.clj:4739)

However I'm able to pass string arguments:

=> (sql/sql (sql/select db [:] (sql/from '(:my-func "abc")))) ["SELECT FROM \"my_func\"(?)" "abc"]

I want to pass the value of arg instead of plain string. How do I do that?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/r0man/sqlingvo/issues/113, or mute the thread https://github.com/notifications/unsubscribe-auth/AABUPs_AzMy45OkxMKtEodjkxjpy6hhnks5uAj9JgaJpZM4U4Aig .