<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,7 @@
 === HEAD
 
+* Make the JDBC adapter accept a :convert_types option to turn off Java type conversion and double performance (jeremyevans)
+
 * Slight increase in ConnectionPool performance (jeremyevans)
 
 * SQL::WindowFunction can now be aliased/casted etc. just like SQL::Function (jeremyevans)</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -203,6 +203,13 @@ Example connections strings:
   jdbc:mysql://localhost/test?user=root&amp;password=root
   jdbc:h2:mem:
 
+The following additional options are supported:
+
+* :convert_types - If set to false, does not attempt to convert some Java types to ruby types.
+  Setting to false roughly doubles performance when selecting large numbers of rows.
+  Note that you can't provide this option inside the connection string (as that is passed
+  directly to JDBC), you have to pass it as a separate option.
+
 === mysql 
 
 The MySQL adapter does not support the pure-ruby MySQL adapter that ships with</diff>
      <filename>doc/opening_databases.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -88,12 +88,18 @@ module Sequel
       # The type of database we are connecting to
       attr_reader :database_type
       
+      # Whether to convert some Java types to ruby types when retrieving rows.
+      # True by default, can be set to false to roughly double performance when
+      # fetching rows.
+      attr_accessor :convert_types
+      
       # Call the DATABASE_SETUP proc directly after initialization,
       # so the object always uses sub adapter specific code.  Also,
       # raise an error immediately if the connection doesn't have a
       # uri, since JDBC requires one.
       def initialize(opts)
         @opts = opts
+        @convert_types = opts.include?(:convert_types) ? typecast_value_boolean(opts[:convert_types]) : true
         raise(Error, &quot;No connection string specified&quot;) unless uri
         if match = /\Ajdbc:([^:]+)/.match(uri) and prok = DATABASE_SETUP[match[1].to_sym]
           prok.call(self)
@@ -418,6 +424,17 @@ module Sequel
         end
       end
       
+      # Whether to convert some Java types to ruby types when retrieving rows.
+      # Uses the database's setting by default, can be set to false to roughly
+      # double performance when fetching rows.
+      attr_accessor :convert_types
+      
+      # Use the convert_types default setting from the database
+      def initialize(db, opts={})
+        @convert_types = db.convert_types
+        super
+      end
+      
       # Correctly return rows from the database and return them as hashes.
       def fetch_rows(sql, &amp;block)
         execute(sql){|result| process_result_set(result, &amp;block)}
@@ -470,10 +487,16 @@ module Sequel
         i = 0
         meta.getColumnCount.times{cols &lt;&lt; [output_identifier(meta.getColumnLabel(i+=1)), i]}
         @columns = cols.map{|c| c.at(0)}
+        row = {}
+        blk = if @convert_types
+          lambda{|n, i| row[n] = convert_type(result.getObject(i))}
+        else
+          lambda{|n, i| row[n] = result.getObject(i)}
+        end
         # get rows
         while result.next
           row = {}
-          cols.each{|n, i| row[n] = convert_type(result.getObject(i))}
+          cols.each(&amp;blk)
           yield row
         end
       end</diff>
      <filename>lib/sequel/adapters/jdbc.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>178c1e4b3acd8be2c823d6a0c50d5dc14a1ecadb</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Evans</name>
    <email>code@jeremyevans.net</email>
  </author>
  <url>http://github.com/jeremyevans/sequel/commit/af2ba1b780afd7013dfd1321dfd708f9816eeb50</url>
  <id>af2ba1b780afd7013dfd1321dfd708f9816eeb50</id>
  <committed-date>2009-07-08T11:23:33-07:00</committed-date>
  <authored-date>2009-07-08T11:23:33-07:00</authored-date>
  <message>Make the JDBC adapter accept a :convert_types option to turn off Java type conversion and double performance

This gives the user the choice to turn off conversion from Java types
to ruby types, in order to roughly double the performance when
fetching rows.  This can be set at both the database and dataset
level:

  DB = Sequel.jdbc('jdbc:postgresql://host/database',
                   :convert_types=&gt;false)
  DB.convert_types = true
  ds = DB[:table]
  ds.convert_types = true

If you turn off Java type conversion, Date, DateTime, Time, and
BigDecimal fields will probably be returned as Java types, which
have a different API than ruby types.  I recommend only turning
it off if there is a bottleneck in your application, and then
only for the dataset that is the bottleneck.  Since Sequel allows
you to modify the setting at the dataset level, that's fairly easy
to do.

Note that the setting is not a database option like :from, its a
setting like quote_identifiers, and modifies the dataset directly
instead of returning a modified copy, so use with care.</message>
  <tree>e69ecdf650c7029710603e556e5c63051e320743</tree>
  <committer>
    <name>Jeremy Evans</name>
    <email>code@jeremyevans.net</email>
  </committer>
</commit>
