Reputation: 123
I'm learning Clojure and I have a question about the basics.
How can I make the function to return the "rows" variable:
(defn list-domains []
(sql/with-connection db
(sql/with-query-results rows ["select * from domains"]
rows)))
thanks
Upvotes: 2
Views: 564
Reputation: 51990
Long time since I've played [FR] with clojure, but as far as I remember, sql/with-query-results
does not return result. It merely evaluate a sub-expression (the last parameter) with the query result as a parameter:
(defn list-domains []
(sql/with-connection db
(sql/with-query-results rows ["select * from domains"]
(do-something-with rows) )))
If you really want to return, you could try to instantiate the sequence by using doall
:
(defn list-domains []
(sql/with-connection db
(sql/with-query-results rows ["select * from domains"]
(doall rows) )))
EDIT: Hum ... well ... as a matter of fact, this is the exact same solution as provided by the documentation for with-query-results
:/
Upvotes: 2