diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2012-09-08 19:51:36 -0400 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2012-09-08 19:51:36 -0400 |
| commit | c4aa26a983c91b1ec015fe0552077847116dfab7 (patch) | |
| tree | da105a932b737c0f42504a2bdf236178afe25160 /django/db/models/sql | |
| parent | a78dd109e6c81c49e90e36e9b793bad67c46c23c (diff) | |
Internal refactoring; moving LOOKUP_SEP up one level.
In an ideal world, nothing except django.db.models.query should have to
import stuff from django.models.sql.*. A few things were needing to get
hold of sql.constants.LOOKUP_SEP, so this commit moves it up to
django.db.models.constants.LOOKUP_SEP.
There are still a couple of places (admin) poking into sql.* to get
QUERY_TERMS, which is unfortunate, but a slightly different issue and
harder to adjust.
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 3 | ||||
| -rw-r--r-- | django/db/models/sql/constants.py | 11 | ||||
| -rw-r--r-- | django/db/models/sql/expressions.py | 2 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 5 | ||||
| -rw-r--r-- | django/db/models/sql/subqueries.py | 1 |
5 files changed, 14 insertions, 8 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index caf2330bd1..28d2404858 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -3,9 +3,10 @@ from django.utils.six.moves import zip from django.core.exceptions import FieldError from django.db import transaction from django.db.backends.util import truncate_name +from django.db.models.constants import LOOKUP_SEP from django.db.models.query_utils import select_related_descend from django.db.models.sql.constants import (SINGLE, MULTI, ORDER_DIR, - LOOKUP_SEP, GET_ITERATOR_CHUNK_SIZE) + GET_ITERATOR_CHUNK_SIZE) from django.db.models.sql.datastructures import EmptyResultSet from django.db.models.sql.expressions import SQLEvaluator from django.db.models.sql.query import get_order_dir, Query diff --git a/django/db/models/sql/constants.py b/django/db/models/sql/constants.py index b9cf2c96fd..f750310624 100644 --- a/django/db/models/sql/constants.py +++ b/django/db/models/sql/constants.py @@ -1,7 +1,13 @@ +""" +Constants specific to the SQL storage portion of the ORM. +""" + from collections import namedtuple import re -# Valid query types (a set is used for speedy lookups). +# 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 = set([ 'exact', 'iexact', 'contains', 'icontains', 'gt', 'gte', 'lt', 'lte', 'in', 'startswith', 'istartswith', 'endswith', 'iendswith', 'range', 'year', @@ -12,9 +18,6 @@ QUERY_TERMS = set([ # 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 (indexes into the tuples that are values in the alias_map # dictionary in the Query class). diff --git a/django/db/models/sql/expressions.py b/django/db/models/sql/expressions.py index 1bbf742b5c..ac8fea6da3 100644 --- a/django/db/models/sql/expressions.py +++ b/django/db/models/sql/expressions.py @@ -1,6 +1,6 @@ from django.core.exceptions import FieldError +from django.db.models.constants import LOOKUP_SEP from django.db.models.fields import FieldDoesNotExist -from django.db.models.sql.constants import LOOKUP_SEP class SQLEvaluator(object): def __init__(self, expression, query, allow_joins=True): diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index f259a2c7d5..77f24fcf24 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -15,11 +15,12 @@ from django.utils.tree import Node from django.utils import six from django.db import connections, DEFAULT_DB_ALIAS from django.db.models import signals +from django.db.models.constants import LOOKUP_SEP from django.db.models.expressions import ExpressionNode from django.db.models.fields import FieldDoesNotExist from django.db.models.sql import aggregates as base_aggregates_module -from django.db.models.sql.constants import (QUERY_TERMS, LOOKUP_SEP, ORDER_DIR, - SINGLE, ORDER_PATTERN, JoinInfo) +from django.db.models.sql.constants import (QUERY_TERMS, ORDER_DIR, SINGLE, + ORDER_PATTERN, JoinInfo) from django.db.models.sql.datastructures import EmptyResultSet, Empty, MultiJoin from django.db.models.sql.expressions import SQLEvaluator from django.db.models.sql.where import (WhereNode, Constraint, EverythingNode, diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index 937505b9b0..c6995c6abb 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -3,6 +3,7 @@ Query subclasses which provide extra functionality beyond simple data retrieval. """ from django.core.exceptions import FieldError +from django.db.models.constants import LOOKUP_SEP from django.db.models.fields import DateField, FieldDoesNotExist from django.db.models.sql.constants import * from django.db.models.sql.datastructures import Date |
