Title: [619] trunk/activerecord-jdbc/lib/jdbc_adapter: Improve performance by hard coding the types for known JDBC drivers.
Revision
619
Author
olabini
Date
2007-06-08 14:25:47 -0400 (Fri, 08 Jun 2007)

Log Message

Improve performance by hard coding the types for known JDBC drivers. (This improves DDL actions with over 25%)

Modified Paths

Diff

Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb (618 => 619)


--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-06-08 15:07:53 UTC (rev 618)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-06-08 18:25:47 UTC (rev 619)
@@ -415,6 +415,23 @@
     def quote_string(s)
       s.gsub(/'/, "''") # ' (for ruby-mode)
     end
+
+    def native_database_types #:nodoc:
+      {
+        :primary_key=>"int generated by default as identity NOT NULL PRIMARY KEY", 
+        :float=>{:name=>"real"}, 
+        :date=>{:name=>"date"}, 
+        :integer=>{:limit=>nil, :name=>"integer"}, 
+        :datetime=>{:name=>"timestamp"}, 
+        :timestamp=>{:name=>"timestamp"}, 
+        :text=>{:name=>"clob"}, 
+        :boolean=>{:name=>"smallint"}, 
+        :time=>{:name=>"time"}, 
+        :decimal=>{:limit=>31, :name=>"decimal"}, 
+        :string=>{:limit=>256, :name=>"varchar"}, 
+        :binary=>{:name=>"blob"}
+      }
+    end
     
 # For DDL it appears you can quote "" column names, but in queries (like insert it errors out?)
     def quote_column_name(name) #:nodoc:

Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mysql.rb (618 => 619)


--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mysql.rb	2007-06-08 15:07:53 UTC (rev 618)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mysql.rb	2007-06-08 18:25:47 UTC (rev 619)
@@ -138,6 +138,23 @@
       end
     end
 
+    def native_database_types #:nodoc:
+      {
+        :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY",
+        :string      => { :name => "varchar", :limit => 255 },
+        :text        => { :name => "text" },
+        :integer     => { :name => "int", :limit => 11 },
+        :float       => { :name => "float" },
+        :decimal     => { :name => "decimal" },
+        :datetime    => { :name => "datetime" },
+        :timestamp   => { :name => "datetime" },
+        :time        => { :name => "time" },
+        :date        => { :name => "date" },
+        :binary      => { :name => "blob" },
+        :boolean     => { :name => "tinyint", :limit => 1 }
+      }
+    end
+
     private
     def supports_views?
       false
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to