On Monday 13 March 2006 21:24, Adrian Holovaty wrote: > On 3/13/06, Luke Plant <[EMAIL PROTECTED]> wrote: > > If I create a model in my app with foreign key to the User model, > > the SQL for creating the table doesn't add a 'REFERENCES' clause: > > [...] > > It works fine for intra-app relations, just not cross-app ones. > > Is this a known issue? Is it by design for some reason? > > That's definitely not by design, or at least my design. (I know a lot > of people have been futzing with the django/core/management.py code > in magic-removal lately, so they should speak up if this is > intentional.) Looks like a bug. Nice catch!
I tracked it down. When doing 'manage.py sql myapp' as opposed to 'syncdb', the list of models doesn't include models from other apps. At this point, it is slightly difficult to work out what is correct behaviour. Should 'sql myapp' print only SQL that will succeed on the existing DB, or should it be agnostic to the contents of the DB? In the latter case, if you printed out the SQL for all your apps you might have to re-order quite a few statements if you wanted to execute them manually, but you wouldn't know which statements needed moving. The solution I've implemented is to add references automatically for tables from other apps that already physically exist (fixing the bug for my case), and at the bottom print commented out SQL statements for those that don't, with an explanatory message. I think it's probably the best of a few bad options. Luke -- "You'll be glad to know, I'm going to donate all the snot I sneeze to hospitals for mucus transfusions." (Calvin and Hobbes) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---