From 4072b70bafd1d140144660712a798380fcd4cddf Mon Sep 17 00:00:00 2001 From: Bret Walker Date: Sat, 2 Feb 2013 23:38:08 -0500 Subject: [PATCH 1/2] Added order_by because I was getting the following error: DatabaseError: SELECT DISTINCT ON expressions must match initial ORDER BY expressions LINE 1: SELECT DISTINCT ON ("db_lookup"."name") "db_lookup"."name", ... --- ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py b/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py index 6d70f60f..a40ac631 100644 --- a/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py +++ b/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py @@ -9,7 +9,7 @@ class Migration(DataMigration): def forwards(self, orm): "Write your forwards methods here." # Ensure names are unique. - for lname in orm['db.lookup'].objects.all().distinct('name').values_list('name'): + for lname in orm['db.lookup'].objects.all().distinct('name'),order_by('name').values_list('name'): lname = lname[0] for sf in orm['db.schemafield'].objects.all(): with_name = orm['db.lookup'].objects.filter(name=lname, schema_field=sf) From 384f86371b9e49186403b20869482156f3100b5f Mon Sep 17 00:00:00 2001 From: Bret Walker Date: Sat, 2 Feb 2013 23:39:33 -0500 Subject: [PATCH 2/2] Fixed typo in last commit. Added order_by because I was getting the following error: DatabaseError: SELECT DISTINCT ON expressions must match initial ORDER BY expressions LINE 1: SELECT DISTINCT ON ("db_lookup"."name") "db_lookup"."name", ... --- ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py b/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py index a40ac631..3413b2f0 100644 --- a/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py +++ b/ebpub/ebpub/db/migrations/0026_make_unique_lookup_names.py @@ -9,7 +9,7 @@ class Migration(DataMigration): def forwards(self, orm): "Write your forwards methods here." # Ensure names are unique. - for lname in orm['db.lookup'].objects.all().distinct('name'),order_by('name').values_list('name'): + for lname in orm['db.lookup'].objects.all().distinct('name').order_by('name').values_list('name'): lname = lname[0] for sf in orm['db.schemafield'].objects.all(): with_name = orm['db.lookup'].objects.filter(name=lname, schema_field=sf)