Wes Gamble
2006-Mar-14 19:42 UTC
[Rails] ActionRecord: Need for "identity"/"serial" columns?
I have a quick question about ActiveRecord and primary key value generation. Does it hurt to define my primary keys as "IDENTITY" (SQL server) or some equivalent database - managed id generation scheme (a la sequences in Oracle, etc.) since ActiveRecord is going to manage my id generation anyway. I''m thinking that for SQL server, even if you define your ids as "IDENTITY" it won''t matter because if you specify a value for an IDENTITY column on an insert, that value will be used instead of the auto-generated value. Anyone have any strong feelings either way? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
Alex Young
2006-Mar-14 20:39 UTC
[Rails] ActionRecord: Need for "identity"/"serial" columns?
Wes Gamble wrote:> I have a quick question about ActiveRecord and primary key value > generation. > > Does it hurt to define my primary keys as "IDENTITY" (SQL server) or > some equivalent database - managed id generation scheme (a la sequences > in Oracle, etc.) since ActiveRecord is going to manage my id generation > anyway. >You have to. ActiveRecord doesn''t manage the ID generation - it relies on the underlying database to do it. Take a look at the defaults supplied by a simple migrated table structure, and you''ll see what it expects. -- Alex
Apparently Analagous Threads
- HABTM join table has an "ID" column - is this an issue?
- text_field doesn''t call overridden ActiveRecord getters
- Wrap error_messages_for() call when no instance var present
- Ajax.Request w/standard redirect doesn''t render
- rake migrate VERSION=0 doesn''t appear to execute