diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index cf7cad29bd..caf2330bd1 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -4,7 +4,8 @@ from django.core.exceptions import FieldError from django.db import transaction from django.db.backends.util import truncate_name from django.db.models.query_utils import select_related_descend -from django.db.models.sql.constants import * +from django.db.models.sql.constants import (SINGLE, MULTI, ORDER_DIR, + LOOKUP_SEP, 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 @@ -811,7 +812,7 @@ class SQLCompiler(object): raise EmptyResultSet except EmptyResultSet: if result_type == MULTI: - return empty_iter() + return iter([]) else: return @@ -1088,13 +1089,6 @@ class SQLDateCompiler(SQLCompiler): yield date -def empty_iter(): - """ - Returns an iterator containing no results. - """ - yield next(iter([])) - - def order_modified_iter(cursor, trim, sentinel): """ Yields blocks of rows from a cursor. We use this iterator in the special diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 1915efa7b9..f259a2c7d5 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -17,9 +17,9 @@ from django.db import connections, DEFAULT_DB_ALIAS from django.db.models import signals from django.db.models.expressions import ExpressionNode from django.db.models.fields import FieldDoesNotExist -from django.db.models.query_utils import InvalidQuery from django.db.models.sql import aggregates as base_aggregates_module -from django.db.models.sql.constants import * +from django.db.models.sql.constants import (QUERY_TERMS, LOOKUP_SEP, 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, @@ -28,6 +28,7 @@ from django.core.exceptions import FieldError __all__ = ['Query', 'RawQuery'] + class RawQuery(object): """ A single raw SQL query diff --git a/tests/modeltests/raw_query/tests.py b/tests/modeltests/raw_query/tests.py index cef9e1be1a..e404c8b065 100644 --- a/tests/modeltests/raw_query/tests.py +++ b/tests/modeltests/raw_query/tests.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from datetime import date -from django.db.models.sql.query import InvalidQuery +from django.db.models.query_utils import InvalidQuery from django.test import TestCase from .models import Author, Book, Coffee, Reviewer, FriendlyAuthor