Sean Corfield <s...@corfield.org> writes: > You said: > > But when the database is already connected like in > > (jdbc/with-db-connection [db db] > (jdbc/query db > query > {:result-set-fn (fn [coll] (doall (take 2 coll))) > :fetch-size 100 > :auto-commit? false})) > > streaming is not turned on. > > Well, of course not: you didn’t tell with-db-connection to do it: > > (jdbc/with-db-connection [db db {:auto-commit? false}] > (jdbc/query db > query > {:result-set-fn (fn [coll] (doall (take 2 coll))) > :fetch-size 100 }))
I think the current behaviour is terrible. I'm passing in {:auto-commit? false}, so please turn off auto commit on the database connection that is being used. The fact that the code currently sets the flag when opening the connection is an implementation detail. It should not leak into the API. Honestly, I don't care if java.jdbc is reusing an existing connection or if it's opening a new connection. Why should it matter in this case? I can use jdbc/query with an existing connection or with a map. It didn't matter until today. Now it surprisingly does. When using functions that receive a db parameter (which may or may not have an open connection attached to it), what are you going to do when you notice that you need streaming? Check if it's using an open connection and call .setAutoCommit on it, and pass {:auto-commit? false} if it's a map? Sorry, but then java.jdbc didn't help me in any way setting up a streaming query. Instead java.jdbc made things *worse* by ignoring my perfectly fine looking option (which has been working when I passed in map) and now tries to burn my laptop with the help from java's garbage collector before throwing a MemoryError. > You have to pass the option into the call that would create the connection. I may not know if (jdbc/query db ...) creates a new connection. I'm not even sure what db is. But I'm sure I want to run a query with streaming results. The fact that I have to set an attribute on the connection object instead of the PreparedStatement is again an implementation detail. Let me pass the required options for streaming when running the query, not when opening the connection. -- Cheers Ralf -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.