diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2012-04-29 17:50:48 -0500 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2012-04-29 17:50:48 -0500 |
| commit | 6ff118cdb9bb5904b8ce3021f52c4450fead49f5 (patch) | |
| tree | e813b4854685b2a3747ab3fe5500e8668b9ea191 /django/db/models/sql/constants.py | |
| parent | af71ce06ead0c42e3c352c4f0afd77abbc3b907d (diff) | |
Fixed #17644 -- Changed Query.alias_map to use namedtuples
This makes the code easier to understand and may even have a benefit in memory usage (namedtuples instead of dicts). Thanks, lrekucki and akaariai
Diffstat (limited to 'django/db/models/sql/constants.py')
| -rw-r--r-- | django/db/models/sql/constants.py | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/django/db/models/sql/constants.py b/django/db/models/sql/constants.py index 63c704fea1..b5fd048799 100644 --- a/django/db/models/sql/constants.py +++ b/django/db/models/sql/constants.py @@ -1,3 +1,4 @@ +from collections import namedtuple import re # Valid query types (a dictionary is used for speedy lookups). @@ -5,7 +6,7 @@ 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', 'week_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. @@ -17,13 +18,9 @@ LOOKUP_SEP = '__' # Constants to make looking up tuple values clearer. # Join lists (indexes into the tuples that are values in the alias_map # dictionary in the Query class). -TABLE_NAME = 0 -RHS_ALIAS = 1 -JOIN_TYPE = 2 -LHS_ALIAS = 3 -LHS_JOIN_COL = 4 -RHS_JOIN_COL = 5 -NULLABLE = 6 +JoinInfo = namedtuple('JoinInfo', + 'table_name rhs_alias join_type lhs_alias ' + 'lhs_join_col rhs_join_col nullable') # How many results to expect from a cursor.execute call MULTI = 'multi' @@ -32,6 +29,5 @@ SINGLE = 'single' ORDER_PATTERN = re.compile(r'\?|[-+]?[.\w]+$') ORDER_DIR = { 'ASC': ('ASC', 'DESC'), - 'DESC': ('DESC', 'ASC')} - - + 'DESC': ('DESC', 'ASC'), +} |
