Title: [574] trunk/activerecord-jdbc/lib/jdbc_adapter: More Derby fixes.
Revision
574
Author
olabini
Date
2007-05-11 12:03:15 -0400 (Fri, 11 May 2007)

Log Message

More Derby fixes. Quote stuff correctly when copying table contents, and also cast to CLOB when necessary.

Modified Paths

Diff

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


--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-05-11 14:45:41 UTC (rev 573)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-05-11 16:03:15 UTC (rev 574)
@@ -309,7 +309,7 @@
     end
     
     def tables
-      super.reject{|t| t =~ /^sys/ }
+      super.reject{|t| t =~ /^sys/i }
     end
     
     # For migrations, exclude the primary key index as recommended
@@ -328,15 +328,12 @@
           case column.type
           when :binary
             "CAST(x'#{quote_string(value).unpack("C*").collect {|v| v.to_s(16)}.join}' AS BLOB)"
+          when :text
+            "CAST('#{quote_string(value)}' AS CLOB)"
           when :string
             "'#{quote_string(value)}'"
           else
-            vi = value.to_i
-            if vi.to_s == value
-              value
-            else
-              "'#{quote_string(value)}'"
-            end
+            super
           end
         else
           super

Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/missing_functionality_helper.rb (573 => 574)


--- trunk/activerecord-jdbc/lib/jdbc_adapter/missing_functionality_helper.rb	2007-05-11 14:45:41 UTC (rev 573)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/missing_functionality_helper.rb	2007-05-11 16:03:15 UTC (rev 574)
@@ -36,7 +36,7 @@
       
       copy_table_indexes(from, to)
       copy_table_contents(from, to, 
-                          @definition.columns.map {|column| column.name}, 
+                          @definition.columns, 
                           options[:rename] || {})
     end
     
@@ -57,13 +57,13 @@
     end
     
     def copy_table_contents(from, to, columns, rename = {}) #:nodoc:
-      column_mappings = Hash[*columns.map {|name| [name, name]}.flatten]
+      column_mappings = Hash[*columns.map {|col| [col.name, col.name]}.flatten]
       rename.inject(column_mappings) {|map, a| map[a.last] = a.first; map}
       from_columns = columns(from).collect {|col| col.name}
-      columns = columns.find_all{|col| from_columns.include?(column_mappings[col])}
+      columns = columns.find_all{|col| from_columns.include?(column_mappings[col.name])}
       execute("SELECT * FROM #{from}").each do |row|
-        sql = "INSERT INTO #{to} ("+columns*','+") VALUES ("            
-        sql << columns.map {|col| quote row[column_mappings[col]]} * ', '
+        sql = "INSERT INTO #{to} ("+columns.map(&:name)*','+") VALUES ("            
+        sql << columns.map {|col| quote(row[column_mappings[col.name]],col)} * ', '
         sql << ')'
         execute sql
       end
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to