Re: [Django] #33907: UniqueConstraints voided when using GenericTabularInline

5 views
Skip to first unread message

Django

unread,
Aug 9, 2022, 10:08:37 AM8/9/22
to django-...@googlegroups.com
#33907: UniqueConstraints voided when using GenericTabularInline
-------------------------------------+-------------------------------------
Reporter: Mohamed Alnahhas | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.1
contrib.contenttypes |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mohamed Alnahhas):

Replying to [comment:4 Simon Charette]:
> I didn't test it out but assume this is happening because
`GenericTabularInline`'s form is passing an `exclude` of either
`{'user','content_type', 'object_id'}` the following statement confused me
though
>
> > However creating the same object through GenericTabularInline gives no
errors and the creation is successful when it should not be.
>
> How is this possible, isn't the database crashing due a unique
constraint violation?
>
> Can you also reproduce the same issue by using `unique_together` instead
of `UniqueConstraint(fields=['user','content_type', 'object_id'],
name='unique_object')`. If you can then I'm not convinced this should be
considered a release blocker.

It is not crashing, the object is created successfully and I get the green
success message I can even go to the Skill_level admin page and see the
duplicate objects. Opening one of the objects and saving without any
changes gives the usual Uniqueconstraints error message.

--
Ticket URL: <https://code.djangoproject.com/ticket/33907#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 9, 2022, 10:11:30 AM8/9/22
to django-...@googlegroups.com
#33907: UniqueConstraints voided when using GenericTabularInline
-------------------------------------+-------------------------------------
Reporter: Mohamed Alnahhas | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.1
contrib.contenttypes |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mohamed Alnahhas):

Replying to [comment:5 Mariusz Felisiak]:


> > However creating the same object through GenericTabularInline gives no

errors and the creation is successful when it should not be. So basically
Useconstraints is not working at all with GenericTabularInline.
>
> I cannot reproduce this issue, it crashes for me (as expected) with:
> {{{
> UNIQUE constraint failed: test_one_skill_level.user_id,
test_one_skill_level.content_type_id, test_one_skill_level.object_id
> }}}
>
> If you're also getting `IntegrityError` than it's a duplicate of #13091.

I am not getting any errors at all, I get the green success message that
the object was created successfully. I tried this on different models and
got the same behavior. I dont know why were not able to reproduce this.

--
Ticket URL: <https://code.djangoproject.com/ticket/33907#comment:7>

Django

unread,
Aug 9, 2022, 12:48:00 PM8/9/22
to django-...@googlegroups.com
#33907: UniqueConstraints voided when using GenericTabularInline
-------------------------------------+-------------------------------------
Reporter: Mohamed Alnahhas | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.1
contrib.contenttypes |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Please attach a sample project. Maybe you're using a database that doesn't
support unique constraints (e.g. MySQL < 8), or a 3rd-party database
backend. It's difficult to say without a sample project.

--
Ticket URL: <https://code.djangoproject.com/ticket/33907#comment:8>

Reply all
Reply to author
Forward
0 new messages