Skip to content

Commit

Permalink
update to Django 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Dec 14, 2024
1 parent f7d63fe commit 23c0de0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: 'mongodb-forks/django'
ref: 'mongodb-5.1.x'
ref: 'mongodb-5.2.x'
path: 'django_repo'
persist-credentials: false
- name: Install system packages for Django's Python test dependencies
Expand Down
2 changes: 1 addition & 1 deletion django_mongodb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "5.1a0"
__version__ = "5.2a0"

# Check Django compatibility before other imports which may fail if the
# wrong version of Django is installed.
Expand Down
7 changes: 4 additions & 3 deletions django_mongodb/lookups.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import NotSupportedError
from django.db.models.fields.related_lookups import In, MultiColSource, RelatedIn
from django.db.models.expressions import ColPairs
from django.db.models.fields.related_lookups import In, RelatedIn
from django.db.models.lookups import (
BuiltinLookup,
FieldGetDbPrepValueIterableMixin,
Expand Down Expand Up @@ -34,8 +35,8 @@ def field_resolve_expression_parameter(self, compiler, connection, sql, param):


def in_(self, compiler, connection):
if isinstance(self.lhs, MultiColSource):
raise NotImplementedError("MultiColSource is not supported.")
if isinstance(self.lhs, ColPairs):
raise NotImplementedError("ColPairs is not supported.")
db_rhs = getattr(self.rhs, "_db", None)
if db_rhs is not None and db_rhs != connection.alias:
raise ValueError(
Expand Down
22 changes: 0 additions & 22 deletions django_mongodb/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,28 +179,6 @@ def execute_sql_flush(self, tables):
if not options.get("capped", False):
collection.delete_many({})

def prep_lookup_value(self, value, field, lookup):
"""
Perform type-conversion on `value` before using as a filter parameter.
"""
if getattr(field, "rel", None) is not None:
field = field.rel.get_related_field()
field_kind = field.get_internal_type()

if lookup in ("in", "range"):
return [
self._prep_lookup_value(subvalue, field, field_kind, lookup) for subvalue in value
]
return self._prep_lookup_value(value, field, field_kind, lookup)

def _prep_lookup_value(self, value, field, field_kind, lookup):
if value is None:
return None

if field_kind == "DecimalField":
value = self.adapt_decimalfield_value(value, field.max_digits, field.decimal_places)
return value

def explain_query_prefix(self, format=None, **options):
# Validate options.
validated_options = {}
Expand Down
5 changes: 1 addition & 4 deletions django_mongodb/query_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ def process_rhs(node, compiler, connection):
value = value[0]
if hasattr(node, "prep_lookup_value_mongo"):
value = node.prep_lookup_value_mongo(value)
# No need to prepare expressions like F() objects.
if hasattr(rhs, "resolve_expression"):
return value
return connection.ops.prep_lookup_value(value, node.lhs.output_field, node.lookup_name)
return value


def regex_match(field, regex_vals, insensitive=False):
Expand Down

0 comments on commit 23c0de0

Please sign in to comment.