<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -54,4 +54,9 @@ db_populate rake tasks
 db_populate includes two rake tasks:
 
 rake db:populate loads all of the data for the current environment
-rake db:migrate_and_populate is the same as calling rake db:migrate followed by rake db:populate
\ No newline at end of file
+rake db:migrate_and_populate is the same as calling rake db:migrate followed by rake db:populate
+
+History
+=======
+2009-03-21 Patch from Ahmed El-Daly to allow PKs with names other than id
+2008-10-11 Initial release
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,10 @@
 Gem::Specification.new do |s|
   s.name     = &quot;db_populate&quot;
-  s.version  = &quot;0.2.0&quot;
-  s.date     = &quot;2008-10-11&quot;
+  s.version  = &quot;0.2.1&quot;
+  s.date     = &quot;2009-03-21&quot;
   s.summary  = &quot;Seed data populator for Rails&quot;
   s.email    = &quot;MikeG1@larkfarm.com&quot;
-  s.homepage = &quot;http://github.com/ffmike/db_populate&quot;
+  s.homepage = &quot;http://github.com/ffmike/db-populate/tree/master&quot;
   s.description = &quot;db_populate provides rake and code support for adding seed data to Rails projects. Forked from a rake task by
   Josh Knowles, plus code by Luke Francl.&quot;
   s.has_rdoc = false</diff>
      <filename>db_populate.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 class ActiveRecord::Base
-  # given a hash of attributes including the ID, look up the record by ID. 
+  # given a hash of attributes including the ID, look up the record by ID.
+  # uses whatever the PK of the model is to do the lookup 
   # If it does not exist, it is created with the rest of the options. 
   # If it exists, it is updated with the given options. 
   #
@@ -7,8 +8,8 @@ class ActiveRecord::Base
   # 
   # Returns the record.
   def self.create_or_update(options = {})
-    id = options.delete(:id)
-    record = find_by_id(id) || new
+    id = options.delete(primary_key.to_sym)
+    record = send(&quot;find_by_#{primary_key}&quot;, id) || new
     record.id = id
     record.attributes = options
     record.save!</diff>
      <filename>lib/create_or_update.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,10 @@ require 'mocha'
 class User &lt; ActiveRecord::Base
 end
 
+class Customer &lt; ActiveRecord::Base
+  set_primary_key &quot;cust_id&quot;
+end
+
 class DbPopulateTest &lt; Test::Unit::TestCase
   
   def test_creates_new_record
@@ -25,5 +29,22 @@ class DbPopulateTest &lt; Test::Unit::TestCase
     assert_equal u.name, &quot;George&quot;
   end
   
+  def test_creates_new_record_with_nonstandard_pk
+    Customer.delete_all
+    Customer.create_or_update(:cust_id =&gt; 1, :name =&gt; &quot;Fred&quot;)
+    assert_equal Customer.count, 1
+    c = Customer.find(:first)
+    assert_equal c.name, &quot;Fred&quot;
+  end
+  
+  def test_updates_existing_record
+    Customer.delete_all
+    Customer.create_or_update(:cust_id =&gt; 1, :name =&gt; &quot;Fred&quot;)
+    Customer.create_or_update(:cust_id =&gt; 1, :name =&gt; &quot;George&quot;)
+    assert_equal Customer.count, 1
+    c = Customer.find(:first)
+    assert_equal c.name, &quot;George&quot;
+  end
+  
 end
 </diff>
      <filename>test/db_populate_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,4 +4,8 @@ ActiveRecord::Schema.define(:version =&gt; 0) do
     t.string   &quot;name&quot;
   end
     
+  create_table &quot;customers&quot;, :primary_key =&gt; 'cust_id', :force =&gt; true do |t|
+    t.string &quot;name&quot;
+  end
+  
 end</diff>
      <filename>test/schema.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fc494218907f5a2df27e05d1eb19efa9d08d6e8e</id>
    </parent>
  </parents>
  <author>
    <name>Mike Gunderloy</name>
    <email>MikeG1@larkfarm.com</email>
  </author>
  <url>http://github.com/ffmike/db-populate/commit/cd5e2a53f4b480ae7078630e76e4bd506316ecc6</url>
  <id>cd5e2a53f4b480ae7078630e76e4bd506316ecc6</id>
  <committed-date>2009-03-21T04:28:27-07:00</committed-date>
  <authored-date>2009-03-21T04:28:27-07:00</authored-date>
  <message>Fix to accomodate non-standard PK columns.</message>
  <tree>ed139688c25f714ce948185687b8da0d391fc3b1</tree>
  <committer>
    <name>Mike Gunderloy</name>
    <email>MikeG1@larkfarm.com</email>
  </committer>
</commit>
