Permalink
Browse files

[soc2010/query-refactor] Fixed a number of issues under postgresql.

  • Loading branch information...
1 parent 183c290 commit 7dcb95ae9a241a896b6b55158d54b741897a1f43 @alex alex committed Jul 1, 2010
Showing with 9 additions and 8 deletions.
  1. +1 −1 django/db/backends/__init__.py
  2. +3 −4 django/db/backends/postgresql/operations.py
  3. +5 −3 django/db/models/base.py
@@ -560,7 +560,7 @@ def sequence_list(self):
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.
@@ -6,10 +6,9 @@
# 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 @@ def sequence_reset_sql(self, style, model_list):
# 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),
View
@@ -5,7 +5,7 @@
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 @@ def save_base(self, raw=False, cls=None, origin=None, force_insert=False,
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]

0 comments on commit 7dcb95a

Please sign in to comment.