diff options
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/oracle/creation.py | 2 | ||||
| -rw-r--r-- | django/db/backends/postgresql/base.py | 2 | ||||
| -rw-r--r-- | django/db/models/base.py | 4 | ||||
| -rw-r--r-- | django/db/models/query.py | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py index af498fa9ff..b1b32dd23e 100644 --- a/django/db/backends/oracle/creation.py +++ b/django/db/backends/oracle/creation.py @@ -109,7 +109,7 @@ def create_test_db(settings, connection, backend, verbosity=1, autoclobber=False settings.DATABASE_USER = TEST_DATABASE_USER settings.DATABASE_PASSWORD = TEST_DATABASE_PASSWD - management.syncdb(verbosity, interactive=False) + management.call_command('syncdb', verbosity=verbosity, interactive=False) # Get a cursor (even though we don't need one yet). This has # the side effect of initializing the test database. diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index d90f0cc225..9d0967fa2b 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -278,7 +278,7 @@ def typecast_string(s): """ Cast all returned strings to unicode strings. """ - if not s: + if not s and not isinstance(s, str): return s return smart_unicode(s) diff --git a/django/db/models/base.py b/django/db/models/base.py index 528bf7fb06..85ddb79fff 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -218,11 +218,11 @@ class Model(object): record_exists = True if pk_set: # Determine whether a record with the primary key already exists. - cursor.execute("SELECT COUNT(*) FROM %s WHERE %s=%%s" % \ + cursor.execute("SELECT 1 FROM %s WHERE %s=%%s" % \ (backend.quote_name(self._meta.db_table), backend.quote_name(self._meta.pk.column)), self._meta.pk.get_db_prep_lookup('exact', pk_val)) # If it does already exist, do an UPDATE. - if cursor.fetchone()[0] > 0: + if cursor.fetchone(): db_values = [f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, False)) for f in non_pks] if db_values: cursor.execute("UPDATE %s SET %s WHERE %s=%%s" % \ diff --git a/django/db/models/query.py b/django/db/models/query.py index f5213ba903..7620c366ce 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -114,7 +114,7 @@ class _QuerySet(object): def __getitem__(self, k): "Retrieve an item or slice from the set of results." - if not isinstance(k, (slice, int)): + if not isinstance(k, (slice, int, long)): raise TypeError assert (not isinstance(k, slice) and (k >= 0)) \ or (isinstance(k, slice) and (k.start is None or k.start >= 0) and (k.stop is None or k.stop >= 0)), \ |
