Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MySQL issues during fixture loading #26

Closed
wants to merge 1 commit into from

Conversation

jsdalton
Copy link

I just installed django-threadedcomments into a project I'm working on but had some issues when I ran tests. In a nutshell, fixtures were failing to load because of foreign key restraint failures, e.g.:

IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`test_myproject`.`threadedcomments_comment`, CONSTRAINT `comment_ptr_id_refs_id_fa2e61cf` FOREIGN KEY (`comment_ptr_id`) REFERENCES `django_comments` (`id`))')

I guess it's possible these fixtures load correctly on other backends? (I imagine this might be why it hasn't been caught until now.) But I had to make two changes to get the fixtures to load properly and for the tests in HierarchyTest to work:

  • Invert the order of the comments and threaded comments in simple_tree.json.
  • Set all values of last_child in simple_tree.json to null, and then update the values in a setUp() method of HierarchyTest.

The common thread in the issues is that if you attempt to add a row with an ID that references a row that has not yet been created, it fails. These fixes resolve this and tests run.

Anyhow, I'm submitting the changes I needed to make to get tests to run as a pull request. Hopefully you'll find this of use. Thanks

@honzakral
Copy link
Owner

This is a bug of MySQL that it doesn't support deferred referential integrity checking. The proposed fix is a bit hackish - if fixtures don't work I would prefer you construct the entire comment tree manually via python. The current solution is a little bit of both which could potentially be very confusing.

Thanks

@jsdalton
Copy link
Author

Yeah, I'll consider that when I re-visit and submit a new pull request if I come up with something cleaner.

The problem is really this one: https://code.djangoproject.com/ticket/3615 , which isn't specific to django-threadedcomments.

Jim Dalton
jim.dalton@furrybrains.com

On Jun 21, 2011, at 8:06 AM, HonzaKral wrote:

This is a bug of MySQL that it doesn't support deferred referential integrity checking. The proposed fix is a bit hackish - if fixtures don't work I would prefer you construct the entire comment tree manually via python. The current solution is a little bit of both which could potentially be very confusing.

Thanks

Reply to this email directly or view it on GitHub:
#26 (comment)

@vdboor
Copy link
Collaborator

vdboor commented May 15, 2013

ok, can I close this ticket? It's open for a long time already.

@vdboor vdboor closed this May 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants