Skip to content

Commit 7dcb95a

Browse files
committed
[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
1 parent 183c290 commit 7dcb95a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

django/db/backends/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ def sequence_list(self):
560560
if not router.allow_syncdb(self.connection.alias, model):
561561
continue
562562
for f in model._meta.local_fields:
563-
if isinstance(f, models.AutoField):
563+
if isinstance(f, models.BaseAutoField):
564564
sequence_list.append({'table': model._meta.db_table, 'column': f.column})
565565
break # Only one AutoField is allowed per model, so don't bother continuing.
566566

django/db/backends/postgresql/operations.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
# used by both the 'postgresql' and 'postgresql_psycopg2' backends.
77

88
class DatabaseOperations(BaseDatabaseOperations):
9-
def __init__(self, connection):
10-
super(DatabaseOperations, self).__init__()
9+
def __init__(self, *args, **kwargs):
10+
super(DatabaseOperations, self).__init__(*args, **kwargs)
1111
self._postgres_version = None
12-
self.connection = connection
1312

1413
def _get_postgres_version(self):
1514
if self._postgres_version is None:
@@ -117,7 +116,7 @@ def sequence_reset_sql(self, style, model_list):
117116
# and column name (available since PostgreSQL 8)
118117

119118
for f in model._meta.local_fields:
120-
if isinstance(f, models.AutoField):
119+
if isinstance(f, models.BaseAutoField):
121120
output.append("%s setval(pg_get_serial_sequence('%s','%s'), coalesce(max(%s), 1), max(%s) %s null) %s %s;" % \
122121
(style.SQL_KEYWORD('SELECT'),
123122
style.SQL_TABLE(model._meta.db_table),

django/db/models/base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import django.db.models.manager # Imported to register signal handler.
66
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS
77
from django.core import validators
8-
from django.db.models.fields import AutoField, FieldDoesNotExist
8+
from django.db.models.fields import BaseAutoField, FieldDoesNotExist
99
from django.db.models.fields.related import OneToOneRel, ManyToOneRel, OneToOneField
1010
from django.db.models.query import delete_objects, Q
1111
from django.db.models.query_utils import CollectedObjects, DeferredAttribute
@@ -514,8 +514,10 @@ def save_base(self, raw=False, cls=None, origin=None, force_insert=False,
514514
if not pk_set:
515515
if force_update:
516516
raise ValueError("Cannot force an update in save() with no primary key.")
517-
values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True), connection=connection))
518-
for f in meta.local_fields if not isinstance(f, AutoField)]
517+
values = [
518+
(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True), connection=connection))
519+
for f in meta.local_fields if not isinstance(f, BaseAutoField)
520+
]
519521
else:
520522
values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True), connection=connection))
521523
for f in meta.local_fields]

0 commit comments

Comments
 (0)