summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-11-05 04:53:47 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-11-05 04:53:47 +0000
commitafcb877128ee5db84b002c66ac640c14e9ea3e08 (patch)
tree6b8949f7494bc81d044dc6286f108bc2c9bfde05
parent20a30ff32ced85ce1bb09abf792af5efc5fed89d (diff)
boulder-oracle-sprint: Made negligible coding style changes
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4019 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/models.py1
-rw-r--r--django/core/management.py8
-rw-r--r--django/db/models/fields/__init__.py28
-rw-r--r--django/db/models/query.py10
4 files changed, 23 insertions, 24 deletions
diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py
index 6cf6ab97c2..35b90cd249 100644
--- a/django/contrib/admin/models.py
+++ b/django/contrib/admin/models.py
@@ -16,7 +16,6 @@ class LogEntry(models.Model):
action_time = models.DateTimeField(_('action time'), auto_now=True)
user = models.ForeignKey(User)
content_type = models.ForeignKey(ContentType, blank=True, null=True)
- #changed for Oracle support
object_id = models.CharField(_('object id'), maxlength=200, blank=True, null=True)
object_repr = models.CharField(_('object repr'), maxlength=200)
action_flag = models.PositiveSmallIntegerField(_('action flag'))
diff --git a/django/core/management.py b/django/core/management.py
index cdb5d23dde..2ada98fb24 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -89,7 +89,7 @@ def get_version():
def get_sql_create(app):
"Returns a list of the CREATE TABLE SQL statements for the given app."
- from django.db import models,get_creation_module, backend
+ from django.db import models, get_creation_module, backend
data_types = get_creation_module().DATA_TYPES
if not data_types:
@@ -169,7 +169,7 @@ def _get_sql_model_create(model, known_models=set()):
field_output.append(style.SQL_KEYWORD('UNIQUE'))
if f.primary_key:
field_output.append(style.SQL_KEYWORD('PRIMARY KEY'))
- if (settings.DATABASE_ENGINE == 'oracle') and f.unique and f.primary_key:
+ if settings.DATABASE_ENGINE == 'oracle' and f.unique and f.primary_key:
# Suppress UNIQUE/PRIMARY KEY for Oracle (ORA-02259)
field_output.remove(style.SQL_KEYWORD('UNIQUE'))
if f.rel:
@@ -198,7 +198,7 @@ def _get_sql_model_create(model, known_models=set()):
final_output.append('\n'.join(full_statement))
# To simulate auto-incrementing primary keys in Oracle -- creating primary tables
- if (settings.DATABASE_ENGINE == 'oracle') & (opts.has_auto_field):
+ if settings.DATABASE_ENGINE == 'oracle' and opts.has_auto_field:
sequence_name = truncate_name('%s_sq' % opts.db_table, backend.get_max_name_length())
sequence_statement = 'CREATE SEQUENCE %s;' % sequence_name
final_output.append(sequence_statement)
@@ -277,7 +277,7 @@ def _get_many_to_many_sql_for_model(model):
final_output.append('\n'.join(table_output))
# To simulate auto-incrementing primary keys in Oracle -- creating m2m tables
- if (settings.DATABASE_ENGINE == 'oracle'):
+ if settings.DATABASE_ENGINE == 'oracle':
m_table = f.m2m_db_table()
sequence_name = truncate_name('%s_sq' % m_table, backend.get_max_name_length())
sequence_statement = 'CREATE SEQUENCE %s;' % sequence_name
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index ab5309a00b..1733d1da40 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -161,7 +161,7 @@ class Field(object):
"Returns field's value prepared for saving into a database."
# Oracle treats empty strings ('') the same as NULLs.
# To get around this wart, we need to change it to something else...
- if settings.DATABASE_ENGINE == 'oracle' and value == '':
+ if settings.DATABASE_ENGINE == 'oracle' and value == '':
value = ' '
return value
@@ -463,11 +463,11 @@ class DateField(Field):
# Casts dates into string format for entry into database.
if isinstance(value, datetime.datetime):
if settings.DATABASE_ENGINE != 'oracle':
- #Oracle does not need a string conversion
+ # Oracle does not need a string conversion
value = value.date().strftime('%Y-%m-%d')
elif isinstance(value, datetime.date):
if settings.DATABASE_ENGINE != 'oracle':
- #Oracle does not need a string conversion
+ # Oracle does not need a string conversion
value = value.strftime('%Y-%m-%d')
return Field.get_db_prep_save(self, value)
@@ -498,19 +498,19 @@ class DateTimeField(DateField):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
if isinstance(value, datetime.datetime):
- # MySQL/Oracle will throw a warning if microseconds are given, because it
- # doesn't support microseconds.
- if (settings.DATABASE_ENGINE == 'mysql' or settings.DATABASE_ENGINE=='oracle') and hasattr(value, 'microsecond'):
+ # MySQL/Oracle will throw a warning if microseconds are given, because
+ # neither database supports microseconds.
+ if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
- # cx_Oracle wants the raw datetime instead of a string
+ # cx_Oracle wants the raw datetime instead of a string.
if settings.DATABASE_ENGINE != 'oracle':
value = str(value)
elif isinstance(value, datetime.date):
- # MySQL/Oracle will throw a warning if microseconds are given, because it
- # doesn't support microseconds.
- if (settings.DATABASE_ENGINE == 'mysql' or settings.DATABASE_ENGINE=='oracle') and hasattr(value, 'microsecond'):
+ # MySQL/Oracle will throw a warning if microseconds are given, because
+ # neither database supports microseconds.
+ if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'):
value = datetime.datetime(value.year, value.month, value.day, microsecond=0)
- # cx_Oracle wants the raw datetime instead of a string
+ # cx_Oracle wants the raw datetime instead of a string.
if settings.DATABASE_ENGINE != 'oracle':
value = str(value)
return Field.get_db_prep_save(self, value)
@@ -518,7 +518,7 @@ class DateTimeField(DateField):
def get_db_prep_lookup(self, lookup_type, value):
# Oracle will throw an error if microseconds are given, because it
# doesn't support microseconds.
- if (settings.DATABASE_ENGINE=='oracle') and hasattr(value, 'microsecond'):
+ if settings.DATABASE_ENGINE == 'oracle' and hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
if lookup_type == 'range':
value = [str(v) for v in value]
@@ -547,8 +547,8 @@ class DateTimeField(DateField):
def flatten_data(self,follow, obj = None):
val = self._get_val_from_obj(obj)
date_field, time_field = self.get_manipulator_field_names('')
- #cx_Oracle does not support strftime
- if (settings.DATABASE_ENGINE=='oracle'):
+ # cx_Oracle does not support strftime
+ if settings.DATABASE_ENGINE == 'oracle':
return {date_field: (val is not None or ''),
time_field: (val is not None or '')}
else:
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 9520924870..19bd504617 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -172,7 +172,7 @@ class _QuerySet(object):
cursor = connection.cursor()
full_query = None
- if (settings.DATABASE_ENGINE == 'oracle'):
+ if settings.DATABASE_ENGINE == 'oracle':
select, sql, params, full_query = self._get_sql_clause()
else:
select, sql, params = self._get_sql_clause()
@@ -203,7 +203,7 @@ class _QuerySet(object):
counter._offset = None
counter._limit = None
counter._select_related = False
- if (settings.DATABASE_ENGINE == 'oracle'):
+ if settings.DATABASE_ENGINE == 'oracle':
select, sql, params, full_query = counter._get_sql_clause()
else:
select, sql, params = counter._get_sql_clause()
@@ -515,7 +515,7 @@ class _QuerySet(object):
sql.append("ORDER BY " + ", ".join(order_by))
# LIMIT and OFFSET clauses
- if (settings.DATABASE_ENGINE != 'oracle'):
+ if settings.DATABASE_ENGINE != 'oracle':
if self._limit is not None:
sql.append("%s " % backend.get_limit_offset_sql(self._limit, self._offset))
else:
@@ -581,7 +581,7 @@ class ValuesQuerySet(QuerySet):
field_names = [f.attname for f in self.model._meta.fields]
cursor = connection.cursor()
- if (settings.DATABASE_ENGINE == 'oracle'):
+ if settings.DATABASE_ENGINE == 'oracle':
select, sql, params, full_query = self._get_sql_clause()
else:
select, sql, params = self._get_sql_clause()
@@ -697,7 +697,7 @@ def get_where_clause(lookup_type, table_prefix, field_name, value):
if table_prefix.endswith('.'):
table_prefix = backend.quote_name(table_prefix[:-1])+'.'
field_name = backend.quote_name(field_name)
- #put some oracle exceptions here
+ # Put some oracle exceptions here
if lookup_type == "icontains" and settings.DATABASE_ENGINE == 'oracle':
return 'lower(%s%s) %s' % (table_prefix, field_name, (backend.OPERATOR_MAPPING[lookup_type] % '%s'))
try: