Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

patch to support importing tables with composite primary keys

#30

I'm using the composite primary keys plugin (http://compositekeys.rubyforge.org/) and found that I couldn't import tables with composite keys because ar-extensions didn't know how to check whether the primary key(s) were being inserted when the primary key was an array:

--- a/ar-extensions/lib/ar-extensions/import.rb
+++ b/ar-extensions/lib/ar-extensions/import.rb
@@ -185,7 +185,11 @@ class ActiveRecord::Base
       # Force the primary key col into the insert if it's not
       # on the list and we are using a sequence and stuff a nil
       # value for it into each row so the sequencer will fire later
-      if !column_names.include?(primary_key) && sequence_name && connection.prefetch_primary_key?
+      # add support for primary keys being an array rather than scalar
+      if ![primary_key].flatten.*.to_sym.to_set.subset?(column_names.*.to_sym.to_set) &&
+          sequence_name && connection.prefetch_primary_key?
          column_names << primary_key
          array_of_attributes.each { |a| a << nil }
       end

Reported by Andy Orahood · July 28th, 2009 @ 03:18 PM

State: new
Milestone: none
Assigned to: Zach Dennis Zach Dennis

Activity

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.