mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
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
This commit is contained in:
parent
20a30ff32c
commit
afcb877128
@ -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'))
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
@ -548,7 +548,7 @@ class DateTimeField(DateField):
|
||||
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'):
|
||||
if settings.DATABASE_ENGINE == 'oracle':
|
||||
return {date_field: (val is not None or ''),
|
||||
time_field: (val is not None or '')}
|
||||
else:
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user