Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#30673 closed Bug (fixed)

Django throws error when different apps with different models have the same name table name.

Reported by: dev-c Owned by: Adnan Umer
Component: Database layer (models, ORM) Version: 2.2
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Error message:
table_name: (models.E028) db_table 'table_name' is used by multiple models: base.ModelName, app2.ModelName.

We have a Base app that points to a central database and that has its own tables. We then have multiple Apps that talk to their own databases. Some share the same table names.
We have used this setup for a while, but after upgrading to Django 2.2 we're getting an error saying we're not allowed 2 apps, with 2 different models to have the same table names.

Is this correct behavior? We've had to roll back to Django 2.0 for now.

Change History (5)

comment:1 by Claude Paroz, 5 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Regression in [5d25804eaf81795c7d457e5a2a9f0b9b0989136c], ticket #20098.
My opinion is that as soon as the project has a non-empty DATABASE_ROUTERS setting, the error should be turned into a warning, as it becomes difficult to say for sure that it's an error. And then the project can add the warning in SILENCED_SYSTEM_CHECKS.

in reply to:  1 comment:2 by Adnan Umer, 5 years ago

Owner: changed from nobody to Adnan Umer
Status: newassigned

I agree with your opinion. Assigning to myself, patch on its way

Replying to Claude Paroz:

Regression in [5d25804eaf81795c7d457e5a2a9f0b9b0989136c], ticket #20098.
My opinion is that as soon as the project has a non-empty DATABASE_ROUTERS setting, the error should be turned into a warning, as it becomes difficult to say for sure that it's an error. And then the project can add the warning in SILENCED_SYSTEM_CHECKS.

comment:3 by Adnan Umer, 5 years ago

Has patch: set
Version 0, edited 5 years ago by Adnan Umer (next)

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 8d351907:

Fixed #30673 -- Relaxed system check for db_table collision when database routers are installed by turning the error into a warning.

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 1265a26b:

[2.2.x] Fixed #30673 -- Relaxed system check for db_table collision when database routers are installed by turning the error into a warning.

Backport of 8d3519071ec001f763b70a3a1f98ae2e980bd552 from master.

Note: See TracTickets for help on using tickets.
Back to Top