Wednesday, October 29, 2014

Re: DB foreign key constraints : Django 1.7 regression ?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBCAAGBQJUUV3fAAoJEC0ft5FqUuEhT54P/RxsN2GgF+BBO/burqaBookO
lNxMNUlHcDYvPDBqXQ52e2AptQaSTIbz0YXTV50TrzqaXm/68ZXWwtVbM3Ygg5jj
Q/F9Jbj94dOt7uuZTXUq0XG9kDhH7DZiLZ1Ez69EjiBMmXX8RuH5/kU+U0/0u0md
D1/ajBxZcAol6UlA46Q6Wtv3DrveKauCF7xJXkbYQxcggkDXmDXQ3jh3KnFjQb6j
tmts8hSA6b+/kklmey3FnLhLPheIj/TnCElF92nwMNWyJIq2E7QtYDe3TQX/SAVY
9Mg7v5FX6t3bTEPbK1zhPDX2W27ecXnHqtytuL8MWWBuzNHfxOwX+1bXhVn09BtV
LZ9PVA1I/z5zu7SgcLaa1eVRRqFdyFBk9hBlIUjGwaBlu3EK6/MA5JOJMJ0UKdJs
ZmDK/w+cwo2O5vssNJ3oZjdVgKJbN/xZ5CaEfZ69sZKwKxt28EzoOIUGqQ8EiXPZ
nApjiCpqpD5mHYjUOaOltt14TSoOZdzldhiivxyRapS5inpsaME+iVATw+LoGvfr
DW2xvKK3XK3fS64SJZpbuK7yCROb28h++7Rx19PYyNbzJzdCywSn8+5kMreXCMZj
RzSJ9Ex4VjHmYE7rkq3Gb/6405sBiObWBWvRRkYsdjkWVhxOwUvXcScr7Hg5dWZ6
oAn2szpkg7gUfKWMaE+3
=UBku
-----END PGP SIGNATURE-----
Hi NotSqrt,

On 10/29/2014 11:53 AM, notsqrt@gmail.com wrote:
> Just tested the following:
>
> * create clean DB
> * run syncdb
> * compare obtained tables when using Django 1.6.8 and Django 1.7.1
>
> My findings :
>
> In Django 1.7, some fields with models.ForeignKey no longer get the DB
> constraint.
>
> In Django 1.6, I indeed get (in postgresql) for instance:
> CONSTRAINT TABLE_FIELD_id_fkey FOREIGN KEY (FIELD_id)
> REFERENCES django_content_type (id) MATCH SIMPLE
> ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY
> DEFERRED,
>
> The models for which it fails are always:
>
> * ContentType
> * Auth.Group
> * Auth.permission
> * django_site
>
> My local apps are always defined after "django.contrib.contenttypes" and
> "django.contrib.auth" in INSTALLED_APPS.
> Putting "django.contrib.contenttypes" as my last app does not change the
> DB construction.
>
> So does it have to do with the order in INSTALLED_APPS ?
> Is it a regression ?

I don't have time to look into this and try to reproduce at the moment,
but if the situation is as you've described it (and it's not due to
something else specific to your project), it is certainly a regression
and a bug. If you can reproduce with a fixed set of steps (starting from
a fresh "startproject" for each Django version), please do file a bug at
code.djangoproject.com with those reproduction instructions. Thanks!

Carl

No comments:

Post a Comment