Hi,
I've been testing out the schema-evolution branch again and hit the
same issue I was having before where it was trying to evolve a model
that hadn't changed. Here are my minimal test case models for this
issue:
from django.db import models
class FooType(models.Model):
name = models.CharField(maxlength=64, unique=True)
class Foo(models.Model):
name = models.CharField(maxlength=64)
foo_type = models.ForeignKey(FooType)
running './manage.py sqlevolve myapp' outputs:
BEGIN;
ALTER TABLE "myapp_foo" ADD COLUMN "name_tmp" varchar(64);
UPDATE "myapp_foo" SET "name_tmp" = "name";
ALTER TABLE "myapp_foo" DROP COLUMN "name";
ALTER TABLE "myapp_foo" RENAME COLUMN "name_tmp" TO "name";
ALTER TABLE "myapp_foo" ALTER COLUMN "name" SET NOT NULL;
COMMIT;
Note that if I rename the FooType model to BarType and do a fresh
install of my application again then run './manage.py sqlevolve myapp'
it outputs the expected:
BEGIN;
COMMIT;
Same goes if I rename the Foo.name field to something else.
This led me to think that some code somewhere is not matching on the
full table name. After a bit of digging I ended up at the
get_known_column_flags() function in
django/db/backends/postgresql/introspection.py on line 100 it reads:
cursor.execute("select pg_constraint.conname, pg_constraint.contype,
pg_attribute.attname from pg_constraint, pg_attribute where
pg_constraint.conrelid=pg_attribute.attrelid and
pg_attribute.attnum=any(pg_constraint.conkey) and
pg_constraint.conname ~ '^%s'" % table_name )
Changing '^%s' to '^%s_' fixes it but I'm not sure if this is the
right way to do it.
Is it?
regards
matthew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers
-~----------~----~----~----~------~----~------~--~---