mirror of
https://github.com/Hopiu/django.git
synced 2026-04-08 09:01:06 +00:00
Refactored compiler SELECT, GROUP BY and ORDER BY generation. While there, also refactored select_related() implementation (get_cached_row() and get_klass_info() are now gone!). Made get_db_converters() method work on expressions instead of internal_type. This allows the backend converters to target specific expressions if need be. Added query.context, this can be used to set per-query state. Also changed the signature of database converters. They now accept context as an argument.
37 lines
1 KiB
Python
37 lines
1 KiB
Python
"""
|
|
Constants specific to the SQL storage portion of the ORM.
|
|
"""
|
|
|
|
import re
|
|
|
|
# Valid query types (a set is used for speedy lookups). These are (currently)
|
|
# considered SQL-specific; other storage systems may choose to use different
|
|
# lookup types.
|
|
QUERY_TERMS = {
|
|
'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in',
|
|
'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year',
|
|
'month', 'day', 'week_day', 'hour', 'minute', 'second', '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
|
|
|
|
# Namedtuples for sql.* internal use.
|
|
|
|
# How many results to expect from a cursor.execute call
|
|
MULTI = 'multi'
|
|
SINGLE = 'single'
|
|
CURSOR = 'cursor'
|
|
NO_RESULTS = 'no results'
|
|
|
|
ORDER_PATTERN = re.compile(r'\?|[-+]?[.\w]+$')
|
|
ORDER_DIR = {
|
|
'ASC': ('ASC', 'DESC'),
|
|
'DESC': ('DESC', 'ASC'),
|
|
}
|
|
|
|
# SQL join types.
|
|
INNER = 'INNER JOIN'
|
|
LOUTER = 'LEFT OUTER JOIN'
|