#2130: Foreign keys sometime not generated correctly
----------------------------+-----------------------------------------------
Reporter: anonymous | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Core framework | Version: SVN
Severity: normal | Keywords:
----------------------------+-----------------------------------------------
I'm experiencing this problem using SQLite.
Consider the model:
{{{
class Fuel(models.Model):
name = models.CharField(maxlength=50)
class Car(models.Model):
fuel = models.ForeignKey(Fuel)
}}}
Running `manage.py sqlall myproject` correctly outputs:
{{{
BEGIN;
CREATE TABLE "pythag_fuel" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(50) NOT NULL
);
CREATE TABLE "pythag_car" (
"id" integer NOT NULL PRIMARY KEY,
"fuel_id" integer NOT NULL REFERENCES "pythag_fuel" ("id")
);
CREATE INDEX pythag_car_fuel_id ON "pythag_car" ("fuel_id");
COMMIT;
}}}
If I rename `Fuel` to `FuelType`:
{{{
class FuelType(models.Model):
name = models.CharField(maxlength=50)
class Car(models.Model):
fuel = models.ForeignKey(FuelType)
}}}
and rerun `manage.py sqlall myproject`, the following is output:
{{{
BEGIN;
CREATE TABLE "pythag_car" (
"id" integer NOT NULL PRIMARY KEY,
"fuel_id" integer NOT NULL
);
CREATE TABLE "pythag_fueltype" (
"id" integer NOT NULL PRIMARY KEY,
"name" varchar(50) NOT NULL
);
-- The following references should be added but depend on non-existant
tables:
CREATE INDEX pythag_car_fuel_id ON "pythag_car" ("fuel_id");
COMMIT;
}}}
The foreign key relationship has not been created correcly in the output
SQL.
--
Ticket URL: <http://code.djangoproject.com/ticket/2130>
Django <http://code.djangoproject.org/>
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---