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.

This project is archived and is in readonly mode.

[PATCH] Sqlite adapter's copy_table should not set :id => true if :id is not a primary key

#1766

Sqlite adapter's copy_table should not set :id => true if :id is not a primary key.

We had a legacy table with a string id. Changing the table was not a good option, according to people more important than me. To recreate the table locally for development, I used a migration like the one below.


create_table :table_name, :id => false do |t|
  t.column :id,                   :string,  :limit => 40, :null => false
  t.column :value,                :integer
end


#later we tried to call

remove_column :table_name, :value

And upon calling remove_column, the whole thing blew up. When SQLiteAdapter tried to call copy_table, it set :id => true and wrote over the original id column.

The following commit will set :id => false if there is an :id column, but it's not a primary_key.

Reported by jdunphy · January 15th, 2009 @ 09:58 PM

State: committed
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. jdunphy
    jdunphy

    Somebody told me that patch files were preferred on single commit type patches. Here's the patch

    January 15th, 2009 @ 10:08 PM

  2. Repository
    Repository
    • State changed from new to committed

    (from [e6493eb9b76de73afef2706493efd090dfff4ecc]) Sqlite adapter's copy_table incorrectly attempts to recreate a primary key id (:id => true in the create_table) if an :id column is present, even if it isn't a primary_key.

    This fix sets :id => false if there is an :id column, but it's not the primary_key.

    Signed-off-by: Michael Koziarski michael@koziarski.com [#1766 [PATCH] Sqlite adapter's copy_table should not set :id => true if :id is not ... state:committed] http://github.com/rails/rails/co...

    January 29th, 2009 @ 04:40 AM