Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions django_mongodb_backend/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def extract(self, compiler, connection):

def func(self, compiler, connection):
lhs_mql = process_lhs(self, compiler, connection)
if self.function is None:
raise NotSupportedError(f"{self} may need an as_mql() method.")
operator = MONGO_OPERATORS.get(self.__class__, self.function.lower())
return {f"${operator}": lhs_mql}

Expand Down
Empty file added tests/db_functions_/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions tests/db_functions_/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import NotSupportedError
from django.db.models import Func
from django.test import SimpleTestCase


class FuncTests(SimpleTestCase):
def test_no_as_mql(self):
msg = "Func() may need an as_mql() method."
with self.assertRaisesMessage(NotSupportedError, msg):
Func().as_mql(None, None)