<< Back to previous view

[JDBC-141] Add get-isolation-level to make it easier to work with nested transactions Created: 31/Aug/16  Updated: 31/Aug/16  Resolved: 31/Aug/16

Status: Resolved
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Sean Corfield Assignee: Sean Corfield
Resolution: Completed Votes: 0
Labels: None


 Description   

Should return the isolation level (as a keyword) for the current connection, if known.






[JDBC-137] make 'result-set-seq' accept customized result-set-read-column to support multi-database environment Created: 07/Aug/16  Updated: 31/Aug/16  Resolved: 31/Aug/16

Status: Resolved
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Zhou Xiangtao Assignee: Sean Corfield
Resolution: Completed Votes: 0
Labels: None


 Description   

Using java.jdbc with postgres composite type, the common way is extend the IResultSetReadColumn protocol. When there are multiple databases in use, every database should specify it's own column reader.
Add option to 'result-set-seq' support custom function to replace IResultSetReadColumn may be a solution for this situation.



 Comments   
Comment by Sean Corfield [ 12/Aug/16 10:03 PM ]

The closest parallel with setting parameters would be to have a :read-columns option (to result-set-seq and upstream in several calling functions, as well as a per-database default in the db-spec itself).

Like :set-parameters, this :read-columns function would be expected to map over the metadata itself – it would be passed the result set object and the result set metadata object, and the default implementation would map over (range 1 (inc (.getColumnCount rsmeta))) and call (.getObject rs idx) and then convert that to Clojure based on the corresponding column in rsmeta.

That feels like a lot of "heavy lifting" but it's what folks have to do if they need per-database set-parameters behavior and it feels like the right approach (given a result set and its metadata, construct an entire row).

Would that solve your problem sufficiently?

Comment by Zhou Xiangtao [ 28/Aug/16 7:13 AM ]

@Sean Corfield

Yes, it would solve the problem. Is the result metadata will make the query execute twice? one for analysis metadata, another for execute the query with data. If so, the result metadata query operation take palpable time or not ? or use result set over result set metadata ?

Comment by Sean Corfield [ 31/Aug/16 7:31 PM ]

The result-set-seq function already has both the metadata and the column data on hand – see this section of the code:

https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L405-L415

Currently the protocol supports a function that is passed the Object (column value), the metadata, and the 1-based column index (into the metadata). I'm suggesting a function that would be passed rs (the result set itself), rsmeta (the metadata), and idxs (the indices), and would return the row values. In the code above, row-values would change to something like:

row-values (fn [] (read-columns rs rsmeta))

And the default behavior would be:

(defn default-read-columns [rs rsmeta idxs]
  (map (fn [^Integer i] (result-set-read-column (.getObject rs i) rsmeta i)) idxs))

(this is slightly simpler than my comment above suggested a few weeks back).

Comment by Sean Corfield [ 31/Aug/16 8:26 PM ]

Will be in next release. An interim 0.6.2-SNAPSHOT release should be available on Sonatype shortly for testing.





[JDBC-142] Incorrect insert! usage in README Created: 02/Sep/16  Updated: 02/Sep/16  Resolved: 02/Sep/16

Status: Resolved
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Trivial
Reporter: Julien Eluard Assignee: Sean Corfield
Resolution: Completed Votes: 0
Labels: None


 Description   

README.md incorrectly uses insert! in the Example Usage section.

It should be:

(j/insert-multi! mysql-db :fruit
  [{:name "Apple" :appearance "rosy" :cost 24}
   {:name "Orange" :appearance "round" :cost 49}])


 Comments   
Comment by Sean Corfield [ 02/Sep/16 1:20 AM ]

Good catch, thank you!

Comment by Sean Corfield [ 02/Sep/16 1:24 AM ]

README updated.





Generated at Wed Sep 28 13:51:36 CDT 2016 using JIRA 4.4#649-r158309.