Skip to content

Commit

Permalink
queryset-refactor: Moved the Query subclasses into their own file.
Browse files Browse the repository at this point in the history
Trying to keep file lengths to something manageable.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7164 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Feb 27, 2008
1 parent 014373b commit 231e735
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 312 deletions.
1 change: 1 addition & 0 deletions django/db/models/sql/__init__.py
@@ -1,4 +1,5 @@
from query import *
from subqueries import *
from where import AND, OR

__all__ = ['Query', 'AND', 'OR']
Expand Down
40 changes: 40 additions & 0 deletions django/db/models/sql/constants.py
@@ -0,0 +1,40 @@
import re

# Valid query types (a dictionary is used for speedy lookups).
QUERY_TERMS = dict([(x, None) for x in (
'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in',
'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year',
'month', 'day', 'isnull', 'search', 'regex', 'iregex',
)])

# Size of each "chunk" for get_iterator calls.
# Larger values are slightly faster at the expense of more storage space.
GET_ITERATOR_CHUNK_SIZE = 100

# Separator used to split filter strings apart.
LOOKUP_SEP = '__'

# Constants to make looking up tuple values clearer.
# Join lists
TABLE_NAME = 0
RHS_ALIAS = 1
JOIN_TYPE = 2
LHS_ALIAS = 3
LHS_JOIN_COL = 4
RHS_JOIN_COL = 5
# Alias map lists
ALIAS_TABLE = 0
ALIAS_REFCOUNT = 1
ALIAS_JOIN = 2
ALIAS_NULLABLE=3

# How many results to expect from a cursor.execute call
MULTI = 'multi'
SINGLE = 'single'

ORDER_PATTERN = re.compile(r'\?|[-+]?\w+$')
ORDER_DIR = {
'ASC': ('ASC', 'DESC'),
'DESC': ('DESC', 'ASC')}


7 changes: 7 additions & 0 deletions django/db/models/sql/datastructures.py
Expand Up @@ -9,6 +9,13 @@ class EmptyResultSet(Exception):
class FullResultSet(Exception):
pass

class Empty(object):
pass

class RawValue(object):
def __init__(self, value):
self.value = value

class Aggregate(object):
"""
Base class for all aggregate-related classes (min, max, avg, count, sum).
Expand Down

0 comments on commit 231e735

Please sign in to comment.