Skip to content

Fixes for Rails 2 / Foreign Keys / Empty fixture directories #6

merged 1 commit into from Sep 19, 2011

2 participants

zilkey commented May 16, 2011

These changes allow Rails 2 users, users with foreign key constraints and users with empty fixture directories to use FixtureBuilder.

rdy commented Sep 16, 2011

is it possible to apply the fix to master branch as it stands? since you are more familiar with the change it might be easier for you to perform the merge at your end first. there has been a pretty big refectoring done so I'm not sure how cleanly this patch will merge.

zilkey commented Sep 19, 2011

Here's the only piece that doesn't seem like it was covered from your recent commits. I tried testing it, but SQLite doesn't have true foreign key constraints, so I couldn't actually get a failing test. I could have just asserted that the disable_referential_integrity method was called, but that seemed dumb.

For the record, the referential integrity change is to make it so that you can delete tables that have foreign keys and data is still referenced by child tables (which happens when there is existing data left in the db after a test run).

CREATE TABLE magical_creatures(
  id serial

CREATE TABLE unicorns(
  magical_creature_id INTEGER,
  FOREIGN KEY(magical_creature_id) REFERENCES magical_creatures(id)

insert into magical_creatures(id) values (1);

insert into unicorns(magical_creature_id) values (1);

drop table magical_creatures; --<< this should raise an error (and does in postgres) but does not

If you need a test in order to apply the patch, I'll have to add a dependency on postgres for the test suite. Let me know what you'd like to do.

rdy commented Sep 19, 2011

this seems fine to me, as long as it works in a repository somewhere with this portion of code, its probably to ok to skip the postgres dependency.

i'll merge it now then push a new version, if you could let me know if the github version works fine with a test repo i'll release a new gem.

@rdy rdy merged commit 2d96ffd into rdy:master Sep 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.