Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mssql/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
if django.VERSION >= (3, 1):
from django.db.models.fields.json import compile_json_path, KeyTransform as json_KeyTransform
if django.VERSION >= (4, 2):
from django.core.exceptions import FullResultSet
from django.core.exceptions import EmptyResultSet, FullResultSet

def _as_sql_agv(self, compiler, connection):
return self.as_sql(compiler, connection, template='%(function)s(CONVERT(float, %(field)s))')
Expand Down Expand Up @@ -241,6 +241,11 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
if django.VERSION >= (4, 2):
try:
where, w_params = self.compile(self.where) if self.where is not None else ("", [])
except EmptyResultSet:
if self.elide_empty:
raise
# Use a predicate that's always False.
where, w_params = "0 = 1", []
except FullResultSet:
where, w_params = "", []
try:
Expand Down