On L, 2007-07-28 at 13:04 +0700, Hendy Irawan wrote: > Tarmo Tänav wrote: > > I'm not actually proposing a mixed system, I'd just like a way to > > load the fixtures like they are currently loaded but do it once > > and only once for all tests. > > > > > I seriously agree with Tarmo. > > Especially painful if trying to use Rails test fixtures and DB integrity > at the same time. In the end I usually let Rails "win", and let Rails > tests & validations do its jobs rather than trying to RI everything into DB. > > It'd be great to be able to specify loading order for the fixtures > globally :)
Load order by itself is not always enough, there can be circular dependencies between tables and even self-referential dependencies in one table. In those cases the only way to mass-load the data (other than manually inserting all the rows in the correct order) is to disable foreign keys completely until all the data has been loaded. This (last I checked) can be done with one simple command in mysql and with a bit of hacking in postgresql (when creating foreign key constraints mark them as deferrable and when loading the fixtures do it inside a transaction and "SET CONSTRAINTS ALL DEFERRED;". So indeed foreign keys can be a pain to use with Rails but the problem can be solved without having to maintain a correct loading order for all the fixtures. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
