Thanks for those details Stefan.  What I'm looking to do is make it so connection.columns sets the primary flag so that when I do a db_schema_dump I can have the create_table have the correct :primary_key value (assuming the default "id" isn't being used).

So if I have:

CREATE TABLE Users (
  UserID int NOT NULL IDENTITY(1,1) PRIMARYKEY,
  Name varchar(100)
)

and do a db_schema_dump I want to get:

create_table "Users", :primary_key => "UserID" do |t|
  t.column "Name", :string, :limit => 100
end

Currently since the connection.columns doesn't set the primary flag for the primary key column and since SchemaDumper doesn't use ActiveRecord::Base (which would set the primary flag) I get:

create_table "users", :id => false do |t|
  t.column "UserID", :integer, :null => false
  t.column "Name", :string, :limit => 100
end

Do people agree that this would be a good change?  Can anyone offer insight into what other adapters might be able to do here?

Thanks,
- Steve

The primary attribute gets set in AciveRecord::Base.columns :

      def columns
        unless @columns
          @columns = connection.columns(table_name, "#{name} Columns")
          @columns.each {|column| column.primary = column.name ==
primary_key}
        end
        @columns
      end

and records the fact that a certain column object represents a primary
key column.

-- stefan

--
For rails performance tuning, see: http://railsexpress.de/blog
Subscription: http://railsexpress.de/blog/xml/rss20/feed.xml

_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core

_______________________________________________
Rails-core mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to