Tarmo Tänav wrote: > 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. > Do you know any plugin which provide this behavior (i.e. disable constraints in Mysql/postgres/etc before fixture load, and enable them after fixture load successful, for every test case?)
Or you have one? It'd be deadly useful!!! thanks (BTW I posted your solution on Ruby Indonesia Wiki at http://wiki.ruby-id.web.id/wiki/Rails_test_fixtures_dengan_referential_integrity , with credits of course. once we have enough content we're planning to release these as a community [CC] licensed book ) -- Hendy Irawan www.hendyirawan.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
