This, of course, was introduced by copy&paste, but at least django should
report this on validate instead of failing when trying to syncdb.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:1>
* cc: bmispelon@… (added)
* has_patch: 0 => 1
* needs_tests: 0 => 1
Comment:
This seems like a good idea but it needs to have tests in order for it to
be merged.
From what I can tell, the tests for the `validate` command go in
`tests/admin_scripts/tests.py`:
https://github.com/django/django/blob/master/tests/admin_scripts/tests.py#L1046
Also, consider adding a `.diff` extension to your patch so that trac can
use syntax highlighting on it.
Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:2>
Comment (by Keryn Knight <django@…>):
It is worth bearing in mind that there are valid use cases for
encountering duplicate table names, such as when using proxy models, or
unmanaged models. The provided patch doesn't seem to account for that, but
I'm not familiar enough with the surrounding code to know whether it is
already handled.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:3>
Comment (by carsten.klein@…):
Thanks for pointing this out. I included a revised version of the patch
including also two test cases, one that tests against a single application
declaring duplicate db tables and one that tests against multiple
applications declaring duplicate db tables.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:4>
Comment (by anonymous):
As proxies reuse the actual model the newly provided patch should be
sufficient.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:5>
Comment (by carsten.klein@…):
Replying to [comment:4 carsten.klein@…]:
> Thanks for pointing this out. I included a revised version of the patch
including also two test cases, one that tests against a single application
declaring duplicate db tables and one that tests against multiple
applications declaring duplicate db tables.
As far as unmanaged models go, these should not be using the ModelBase
meta class then, or would they?
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:6>
Comment (by bmispelon):
There's a typo in the added comment:
> Lookup table for table names introduced in order to prevent that users
from declaring the same table twice
Regarding unmanaged and proxy models, I'm not familiar enough with the
code to tell if they are handled with this patch but one surefire way to
tell would be to add some tests that use them.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:7>
Comment (by carsten.klein@…):
Included the newly added apps for backing the test cases.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:8>
Comment (by carsten.klein@…):
As a side effect this should also detect copy&paste errors such as
duplicating a model class and failing to rename it and updating its Meta
accordingly.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:9>
Comment (by carsten.klein@…):
Replying to [comment:3 Keryn Knight <django@…>]:
> It is worth bearing in mind that there are valid use cases for
encountering duplicate table names, such as when using proxy models, or
unmanaged models. The provided patch doesn't seem to account for that, but
I'm not familiar enough with the surrounding code to know whether it is
already handled.
Just had a look at the documentation on unmanaged models. It seems that
this is a special case that needs to be dealt with. I will add a guard to
the patch and a test case that also includes unmanaged models.
Thanks for pointing this out!
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:10>
* type: Cleanup/optimization => New feature
* version: 1.5 => master
* component: Database layer (models, ORM) => Core (System checks)
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:11>
* owner: nobody => Sanyam Khurana
* status: new => assigned
Comment:
There is a lot of regression in applying the patch cleanly which revolve
mostly around the test cases within Django. I'm working to modify the last
version of the patch, cleanly apply it to the master branch and fix test
cases.
PR will be up soon.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:12>
* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin
Comment:
Not sure if it's worth adding a co-author given the final patch is quite
different from the original one here.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:13>
Comment (by Sanyam Khurana):
Hello Tim,
I've addressed your reviews on the patch. Can you please have a look at
this when you've some time?
Please let me know if there are any more changes needed.
Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:14>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"5d25804eaf81795c7d457e5a2a9f0b9b0989136c" 5d25804]:
{{{
#!CommitTicketReference repository=""
revision="5d25804eaf81795c7d457e5a2a9f0b9b0989136c"
Fixed #20098 -- Added a check for model Meta.db_table collisions.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:15>
Comment (by Claude Paroz):
Note that a regression was spotted in #30673.
--
Ticket URL: <https://code.djangoproject.com/ticket/20098#comment:16>