home / django_tickets / tickets

tickets: 6475

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
6475 2008-01-28 11:47:05 2008-01-28 14:05:12 2022-03-06 03:37:14.761167 Unreviewed closed Core (Other)     dev duplicate some SQL constraint statements commented out in generated sql == To Reproduce == Set up a django project and app, and set up an appropriate database. Put the following code in the app's models.py: {{{ from django.db import models class A(models.Model): b_ref = models.ForeignKey('B') class B(models.Model): a_ref = models.ForeignKey(A) }}} Then run {{{python manage.py sql <appname>}}} == Output == {{{ BEGIN; CREATE TABLE `testapp_a` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `b_ref_id` integer NOT NULL ) ; CREATE TABLE `testapp_b` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `a_ref_id` integer NOT NULL ) ; ALTER TABLE `testapp_a` ADD CONSTRAINT b_ref_id_refs_id_2727239a FOREIGN KEY (`b_ref_id`) REFERENCES `testapp_b` (`id`); -- The following references should be added but depend on non-existent tables: -- ALTER TABLE `testapp_b` ADD CONSTRAINT a_ref_id_refs_id_3bce8de8 FOREIGN KEY (`a_ref_id`) REFERENCES `testapp_a` (`id`); COMMIT; }}} == Expected Output == Same as output except that the last ALTER TABLE statement should not be commented out. == Patch == I have made a patch, but my python is a bit rusty... nobody railk   0 1 0 0 0 0
Powered by Datasette · Queries took 1.003ms