Skip to content

Commit be27ae6

Browse files
committed
use default value when value is missing
1 parent 4a0b830 commit be27ae6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

django_mongodb/compiler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django.core.exceptions import EmptyResultSet, FullResultSet
22
from django.db import DatabaseError, IntegrityError, NotSupportedError
3-
from django.db.models import NOT_PROVIDED, Count, Expression
3+
from django.db.models import Count, Expression
44
from django.db.models.aggregates import Aggregate
55
from django.db.models.constants import LOOKUP_SEP
66
from django.db.models.sql import compiler
@@ -73,6 +73,7 @@ def _make_result(self, entity, columns):
7373
"""
7474
result = []
7575
for name, col in columns:
76+
field = col.field
7677
column_alias = getattr(col, "alias", None)
7778
obj = (
7879
# Use the related object...
@@ -81,7 +82,8 @@ def _make_result(self, entity, columns):
8182
if column_alias is not None and column_alias != self.collection_name
8283
else entity
8384
)
84-
result.append(obj.get(name, NOT_PROVIDED))
85+
value = obj.get(name, field.get_default())
86+
result.append(value)
8587
return result
8688

8789
def check_query(self):

0 commit comments

Comments
 (0)