From 7dcb95ae9a241a896b6b55158d54b741897a1f43 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 1 Jul 2010 01:53:05 +0000 Subject: [PATCH] [soc2010/query-refactor] Fixed a number of issues under postgresql. git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/query-refactor@13408 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/backends/__init__.py | 2 +- django/db/backends/postgresql/operations.py | 7 +++---- django/db/models/base.py | 8 +++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 289f807507..eac227792e 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -560,7 +560,7 @@ class BaseDatabaseIntrospection(object): if not router.allow_syncdb(self.connection.alias, model): continue for f in model._meta.local_fields: - if isinstance(f, models.AutoField): + if isinstance(f, models.BaseAutoField): sequence_list.append({'table': model._meta.db_table, 'column': f.column}) break # Only one AutoField is allowed per model, so don't bother continuing. diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py index 76f25410fb..e5dd0fdd11 100644 --- a/django/db/backends/postgresql/operations.py +++ b/django/db/backends/postgresql/operations.py @@ -6,10 +6,9 @@ from django.db.backends import BaseDatabaseOperations # used by both the 'postgresql' and 'postgresql_psycopg2' backends. class DatabaseOperations(BaseDatabaseOperations): - def __init__(self, connection): - super(DatabaseOperations, self).__init__() + def __init__(self, *args, **kwargs): + super(DatabaseOperations, self).__init__(*args, **kwargs) self._postgres_version = None - self.connection = connection def _get_postgres_version(self): if self._postgres_version is None: @@ -117,7 +116,7 @@ class DatabaseOperations(BaseDatabaseOperations): # and column name (available since PostgreSQL 8) for f in model._meta.local_fields: - if isinstance(f, models.AutoField): + if isinstance(f, models.BaseAutoField): output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \ (style.SQL_KEYWORD('SELECT'), style.SQL_TABLE(model._meta.db_table), diff --git a/django/db/models/base.py b/django/db/models/base.py index 6304e009d3..3e8b54ce19 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -5,7 +5,7 @@ from itertools import izip import django.db.models.manager # Imported to register signal handler. from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS from django.core import validators -from django.db.models.fields import AutoField, FieldDoesNotExist +from django.db.models.fields import BaseAutoField, FieldDoesNotExist from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField from django.db.models.query import delete_objects, Q from django.db.models.query_utils import CollectedObjects, DeferredAttribute @@ -514,8 +514,10 @@ class Model(object): if not pk_set: if force_update: raise ValueError("Cannot force an update in save() with no primary key.") - values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True), connection=connection)) - for f in meta.local_fields if not isinstance(f, AutoField)] + values = [ + (f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True), connection=connection)) + for f in meta.local_fields if not isinstance(f, BaseAutoField) + ] else: values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True), connection=connection)) for f in meta.local_fields]