Re: [Django] #30524: on_delete doesn't work properly with MySql.

2019-05-28 Thread Django
#30524: on_delete doesn't work properly with MySql.
---+--
 Reporter:  dheeraj135 |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  Uncategorized  |  Version:  2.2
 Severity:  Normal |   Resolution:  invalid
 Keywords:  Foreign Key| Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by Simon Charette):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Django doesn't support database level foreign keys yet, this is tracked in
 #11964.

 The `models.CASCADE` value implements cascade deletion at the
 application/Python level in order to support signals.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.698f1d58ff8c30a18f7a77ca3355cb3b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #30524: on_delete doesn't work properly with MySql.

2019-05-28 Thread Django
#30524: on_delete doesn't work properly with MySql.
---+--
 Reporter:  dheeraj135 |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Uncategorized  |  Version:  2.2
 Severity:  Normal |   Resolution:
 Keywords:  Foreign Key| Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by dheeraj135):

 * keywords:  Foreign Key, indexes => Foreign Key


Old description:

> Model:
>
> {{{
> class Attempt(models.Model):
> student = models.ForeignKey(Student, models.CASCADE,
> related_name='quiz_attempts',null=False)
> quiz =
> models.ForeignKey(Quiz,on_delete=models.CASCADE,related_name='quiz_attempts')
> score = models.FloatField()
> over = models.BooleanField(default=False)
> date = models.DateTimeField(auto_now_add=True)
> currquestion =
> models.ForeignKey(Question,null=True,default=None,on_delete=models.SET_NULL)
>
> class Meta:
> indexes = [
> models.Index(fields=['student']),
> models.Index(fields=['quiz']),
> ]
>
> }}}
> Table created in MySql:
>
> {{{
> CREATE TABLE `classroom_attempt` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `score` double NOT NULL,
>   `over` tinyint(1) NOT NULL,
>   `date` datetime(6) NOT NULL,
>   `currquestion_id` int(11) DEFAULT NULL,
>   `quiz_id` int(11) NOT NULL,
>   `student_id` int(11) NOT NULL,
>   PRIMARY KEY (`id`),
>   KEY `classroom_a_student_1a21bc_idx` (`student_id`),
>   KEY `classroom_a_quiz_id_eef64a_idx` (`quiz_id`),
>   KEY `classroom_attempt_currquestion_id_545301ef_fk_classroom`
> (`currquestion_id`),
>   CONSTRAINT `classroom_attempt_currquestion_id_545301ef_fk_classroom`
> FOREIGN KEY (`currquestion_id`) REFERENCES `classroom_question` (`id`),
>   CONSTRAINT `classroom_attempt_quiz_id_e227b203_fk_classroom_quiz_id`
> FOREIGN KEY (`quiz_id`) REFERENCES `classroom_quiz` (`id`),
>   CONSTRAINT `classroom_attempt_student_id_a4dc81cd_fk_classroom` FOREIGN
> KEY (`student_id`) REFERENCES `classroom_student` (`user_id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
> +---+-
> }}}
>
> As you can notice, indexes and models.CASCADE is not applied.

New description:

 Model:

 {{{
 class Attempt(models.Model):
 student = models.ForeignKey(Student, models.CASCADE,
 related_name='quiz_attempts',null=False)
 quiz =
 models.ForeignKey(Quiz,on_delete=models.CASCADE,related_name='quiz_attempts')
 score = models.FloatField()
 over = models.BooleanField(default=False)
 date = models.DateTimeField(auto_now_add=True)
 currquestion =
 models.ForeignKey(Question,null=True,default=None,on_delete=models.SET_NULL)

 class Meta:
 indexes = [
 models.Index(fields=['student']),
 models.Index(fields=['quiz']),
 ]

 }}}
 Table created in MySql:

 {{{
 CREATE TABLE `classroom_attempt` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `score` double NOT NULL,
   `over` tinyint(1) NOT NULL,
   `date` datetime(6) NOT NULL,
   `currquestion_id` int(11) DEFAULT NULL,
   `quiz_id` int(11) NOT NULL,
   `student_id` int(11) NOT NULL,
   PRIMARY KEY (`id`),
   KEY `classroom_a_student_1a21bc_idx` (`student_id`),
   KEY `classroom_a_quiz_id_eef64a_idx` (`quiz_id`),
   KEY `classroom_attempt_currquestion_id_545301ef_fk_classroom`
 (`currquestion_id`),
   CONSTRAINT `classroom_attempt_currquestion_id_545301ef_fk_classroom`
 FOREIGN KEY (`currquestion_id`) REFERENCES `classroom_question` (`id`),
   CONSTRAINT `classroom_attempt_quiz_id_e227b203_fk_classroom_quiz_id`
 FOREIGN KEY (`quiz_id`) REFERENCES `classroom_quiz` (`id`),
   CONSTRAINT `classroom_attempt_student_id_a4dc81cd_fk_classroom` FOREIGN
 KEY (`student_id`) REFERENCES `classroom_student` (`user_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
 +---+-
 }}}

 As you can notice models.CASCADE is not applied.

--

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.6aae07dca151807adb1948de382b82a9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.