|
0
|
1 |
import re |
|
|
2 |
|
|
|
3 |
# Valid query types (a dictionary is used for speedy lookups). |
|
|
4 |
QUERY_TERMS = dict([(x, None) for x in ( |
|
|
5 |
'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in', |
|
|
6 |
'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year', |
|
|
7 |
'month', 'day', 'week_day', 'isnull', 'search', 'regex', 'iregex', |
|
|
8 |
)]) |
|
|
9 |
|
|
|
10 |
# Size of each "chunk" for get_iterator calls. |
|
|
11 |
# Larger values are slightly faster at the expense of more storage space. |
|
|
12 |
GET_ITERATOR_CHUNK_SIZE = 100 |
|
|
13 |
|
|
|
14 |
# Separator used to split filter strings apart. |
|
|
15 |
LOOKUP_SEP = '__' |
|
|
16 |
|
|
|
17 |
# Constants to make looking up tuple values clearer. |
|
|
18 |
# Join lists (indexes into the tuples that are values in the alias_map |
|
|
19 |
# dictionary in the Query class). |
|
|
20 |
TABLE_NAME = 0 |
|
|
21 |
RHS_ALIAS = 1 |
|
|
22 |
JOIN_TYPE = 2 |
|
|
23 |
LHS_ALIAS = 3 |
|
|
24 |
LHS_JOIN_COL = 4 |
|
|
25 |
RHS_JOIN_COL = 5 |
|
|
26 |
NULLABLE = 6 |
|
|
27 |
|
|
|
28 |
# How many results to expect from a cursor.execute call |
|
|
29 |
MULTI = 'multi' |
|
|
30 |
SINGLE = 'single' |
|
|
31 |
|
|
|
32 |
ORDER_PATTERN = re.compile(r'\?|[-+]?[.\w]+$') |
|
|
33 |
ORDER_DIR = { |
|
|
34 |
'ASC': ('ASC', 'DESC'), |
|
|
35 |
'DESC': ('DESC', 'ASC')} |
|
|
36 |
|
|
|
37 |
|