This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-29
Channels
- # announcements (8)
- # aws (34)
- # beginners (92)
- # calva (19)
- # capetown (1)
- # cider (10)
- # cljs-dev (7)
- # cljsrn (11)
- # clojars (7)
- # clojure (130)
- # clojure-europe (4)
- # clojure-italy (4)
- # clojure-losangeles (1)
- # clojure-nl (11)
- # clojure-russia (1)
- # clojure-spec (4)
- # clojure-uk (64)
- # clojurescript (51)
- # cursive (9)
- # data-science (6)
- # datomic (29)
- # emacs (3)
- # figwheel-main (14)
- # fulcro (4)
- # graphql (3)
- # jackdaw (2)
- # jobs (4)
- # kaocha (17)
- # leiningen (3)
- # luminus (1)
- # off-topic (46)
- # pedestal (6)
- # portkey (2)
- # re-frame (6)
- # reagent (1)
- # reitit (9)
- # shadow-cljs (9)
- # sql (10)
- # yada (6)
I'm trying to achieve something like this:
select * from versions where (group_id, artifact_id, name) IN (VALUES ('reagent', 'reagent', '0.8.1'), ('re-frame', 're-frame', '0.10.4'));
but am unsure about the right way to write this. Tried the following but that gives me [SQLITE_ERROR] SQL error or missing database (near "?": syntax error)
(sql/query db-spec
["select * from versions where (group_id, artifact_id, name) IN ?"
[["re-frame" "re-frame" "0.10.4"]]])
Do I need to extend ISQLValue for this type of thing or am I missing something?found this old mailing list post which says that IN
isn't supported by clojure.jdbc: https://groups.google.com/forum/#!topic/clojure/7A_HAAISvEk
HugSQL supports IN clauses with its Value List Parameter: https://www.hugsql.org/#param-value-list
And, based on your usage of SQL tuples, you could use HugSQL's Tuple List Parameters as well: https://www.hugsql.org/#param-tuple-list
Thanks, that's very helpful! 🙂
In the same vein I'm also wondering how I can see the final string representation of a fully prepared statement
You may want to read https://stackoverflow.com/questions/2382532/how-can-i-get-the-sql-of-a-preparedstatement
Iirc, I used a dynamic variable to print the jdbc array in helper functions that wrapped honeysql's format. The code is here: https://github.com/curiosity/curiosity.components/blob/master/src/curiosity/components/jdbc.clj