#2225: 'manage.py sql ...' gets confused when using tables from separate apps ---------------------------------------------------+------------------------ Reporter: Lucas Hazel | Owner: anonymous Status: assigned | Milestone: Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by glassresis...@gmail.com):
* owner: nobody => anonymous * status: new => assigned Comment: Came across this today looking for an easy bug fix. I can confirm that the error still exists in the current trunk, that syncdb does work even though sql implies that it will not work. Below I have the output for 3 models in 2 apps the foreign key inside model C has no errors but model B which is in a different app isn't aware of table app1_a's existance. Should be able to copy how reference checking works inside apps and extend it to check other apps as well within the sql management command in the same way syncdb does this, unless its just coincidental that app1_a gets created before app2_b and then syncdb will also need some reworking. {{{ (svn)m...@vsolanis:~/django/testtables$ python ./manage.py sql app1 app2 BEGIN; CREATE TABLE "app1_a" ( "id" serial NOT NULL PRIMARY KEY, "article_body" text NOT NULL ) ; CREATE TABLE "app1_c" ( "id" serial NOT NULL PRIMARY KEY, "key_id" integer NOT NULL REFERENCES "app1_a" ("id") DEFERRABLE INITIALLY DEFERRED ) ; CREATE TABLE "app2_b" ( "id" serial NOT NULL PRIMARY KEY, "a_id" integer NOT NULL ) ; -- The following references should be added but depend on non-existent tables: -- ALTER TABLE "app2_b" ADD CONSTRAINT "a_id_refs_id_ea2536ff" FOREIGN KEY ("a_id") REFERENCES "app1_a" ("id") DEFERRABLE INITIALLY DEFERRED; COMMIT; }}} -- Ticket URL: <http://code.djangoproject.com/ticket/2225#comment:4> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.