1
0
mirror of https://github.com/django/django.git synced 2025-07-04 17:59:13 +00:00

boulder-oracle-sprint: Fixed Oracle limit-offset logic and many_to_one test

case.


git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4078 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Boulder Sprinters 2006-11-16 16:25:59 +00:00
parent 19773e0d70
commit 525f81d091
5 changed files with 84 additions and 73 deletions

View File

@ -143,15 +143,15 @@ def get_max_name_length():
OPERATOR_MAPPING = { OPERATOR_MAPPING = {
'exact': '= %s', 'exact': '= %s',
'iexact': 'LIKE %s', 'iexact': "LIKE %s ESCAPE '\\'",
'contains': 'LIKE %s', 'contains': "LIKE %s ESCAPE '\\'",
'icontains': 'LIKE %s', 'icontains': "LIKE %s ESCAPE '\\'",
'gt': '> %s', 'gt': '> %s',
'gte': '>= %s', 'gte': '>= %s',
'lt': '< %s', 'lt': '< %s',
'lte': '<= %s', 'lte': '<= %s',
'startswith': 'LIKE %s', 'startswith': "LIKE %s ESCAPE '\\'",
'endswith': 'LIKE %s', 'endswith': "LIKE %s ESCAPE '\\'",
'istartswith': 'LIKE %s', 'istartswith': "LIKE %s ESCAPE '\\'",
'iendswith': 'LIKE %s', 'iendswith': "LIKE %s ESCAPE '\\'",
} }

View File

@ -53,6 +53,7 @@ def get_query_set_class(DefaultQuerySet):
extra_select = self._select.items() extra_select = self._select.items()
full_query = None full_query = None
select, sql, params, full_query = self._get_sql_clause() select, sql, params, full_query = self._get_sql_clause()
if not full_query: if not full_query:
full_query = "SELECT %s%s\n%s" % \ full_query = "SELECT %s%s\n%s" % \
@ -170,10 +171,20 @@ def get_query_set_class(DefaultQuerySet):
(backend.quote_name(opts.db_table), (backend.quote_name(opts.db_table),
backend.quote_name(opts.fields[0].db_column or opts.fields[0].column)) backend.quote_name(opts.fields[0].db_column or opts.fields[0].column))
# limit_and_offset_clause # limit_and_offset_clause
offset = self._offset and int(self._offset) or 0 if self._limit is None:
limit = self._limit and int(self._limit) or None assert self._offset is None, "'offset' is not allowed without 'limit'"
if self._offset is not None:
offset = int(self._offset)
else:
offset = 0
if self._limit is not None:
limit = int(self._limit)
else:
limit = None
limit_and_offset_clause = '' limit_and_offset_clause = ''
if limit: if limit is not None:
limit_and_offset_clause = "WHERE rn > %s AND rn <= %s" % (offset, limit+offset) limit_and_offset_clause = "WHERE rn > %s AND rn <= %s" % (offset, limit+offset)
elif offset: elif offset:
limit_and_offset_clause = "WHERE rn > %s" % (offset) limit_and_offset_clause = "WHERE rn > %s" % (offset)

View File

@ -146,7 +146,7 @@ False
# The underlying query only makes one join when a related table is referenced twice. # The underlying query only makes one join when a related table is referenced twice.
>>> query = Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith') >>> query = Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith')
>>> null, sql, null = query._get_sql_clause() >>> null, sql, null, null = query._get_sql_clause()
>>> sql.count('INNER JOIN') >>> sql.count('INNER JOIN')
1 1