Title: [563] trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb: Monkeypatch Rails to avoid the quoting problem in Derby.
Revision
563
Author
olabini
Date
2007-05-09 09:33:02 -0400 (Wed, 09 May 2007)

Log Message

Monkeypatch Rails to avoid the quoting problem in Derby.

Modified Paths


Diff

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


--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-05-08 20:13:31 UTC (rev 562)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_derby.rb	2007-05-09 13:33:02 UTC (rev 563)
@@ -299,12 +299,7 @@
             end
           end
         else
-          vi = value.to_i
-          if vi.to_s == value
-            value
-          else
-            "'#{quote_string(value)}'"
-          end
+          super
         end
       else super
       end
@@ -332,3 +327,26 @@
     end
   end
 end
+
+# Needed because Rails is broken wrt to quoting of 
+# some values. Most databases are nice about it,
+# but not Derby. The real issue is that you can't
+# compare a CHAR value to a NUMBER column.
+module ActiveRecord::Associations::ClassMethods
+  private
+
+  def select_limited_ids_list(options, join_dependency)
+    connection.select_all(
+      construct_finder_sql_for_association_limiting(options, join_dependency),
+      "#{name} Load IDs For Limited Eager Loading"
+    ).collect { |row| quote_primary_key(row[primary_key]) }.join(", ")
+  end
+
+  def quote_primary_key(value)
+    if parent.respond_to? :quote_value
+      parent.quote_value(value, parent.columns_hash[parent.primary_key])
+    else
+      connection.quote(value)
+    end
+  end
+end 
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to