This is the reference: (not sure if I interpreted it right - sorry,
newb :)

"If you use a multiple-table UPDATE  statement involving InnoDB tables
for which there are foreign key constraints, the MySQL optimizer might
process tables in an order that differs from that of their parent/
child relationship. In this case, the statement fails and rolls back.
Instead, update a single table and rely on the ON UPDATE capabilities
that InnoDB provides to cause the other tables to be modified
accordingly. See Section 13.5.5.4, “FOREIGN KEY Constraints”."

from: http://dev.mysql.com/doc/refman/5.1/en/update.html
+ 
http://www.dbforums.com/mysql/1191227-cannot-delete-update-parent-row-foreign-key-constraint-fails.html


On Jan 9, 10:23 pm, Tony <tony.0.tho...@gmail.com> wrote:
> I read somewhere that InnoDB cant determine the order to apply DB
> operations to rows when the request spans multiple tables??? (i.e.
> constraint violation???) Is anyone using MySQL + InnoDB and having
> similar issues?  or is is it the norm to process models in Django on a
> per model basis instead of letting the DB cascade deletes across
> models?
>
> On Jan 8, 11:17 pm, Tony <tony.0.tho...@gmail.com> wrote:
>
> > Dear List,
>
> > I'm developing with 1.0.2 and am getting the following error:
>
> > (1451, 'Cannot delete or update a parent row: a foreign key constraint
> > fails (`project/comment_comment`, CONSTRAINT
> > `in_reply_to_id_refs_id_35b80077` FOREIGN KEY (`in_reply_to_id`)
> > REFERENCES `comment_comment` (`id`))')
>
> > ... where the Comment model i've defined is:
>
> > class Comment(models.Model):
> >   objects = CommentManager()
>
> >   user = models.ForeignKey(User)
> >   title = models.CharField(max_length=60)
> >   comment = models.TextField()
> >   content_type = models.ForeignKey(ContentType)
> >   object_id = models.PositiveIntegerField()
> >   owner = generic.GenericForeignKey('content_type', 'object_id')
> >   in_reply_to = models.ForeignKey('self', null=True, blank=True,
> > related_name='reply_to')
> >   rating = models.FloatField(default=5.00)
> >   created = models.DateTimeField('date created', auto_now_add=True)
>
> > ... when trying to delete the owner object (genericforeignkey) and
> > when there are two comments pointing to the owner object - one with
> > in_reply_to == None, and the other with in_reply_to == the first
> > comment. The cascade works fine if I try to delete the first comment,
> > but when i'm trying to delete the owner object the error comes up???
> > Could anyone please help me understand why this exception is being
> > thrown, and how to possibly fix it?
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to