Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Jan 1, 2025
1 parent 9f1781c commit 6a97c8e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions django_mongodb/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,18 @@ def value(self, compiler, connection): # noqa: ARG001
if isinstance(value, datetime.datetime):
return value
if isinstance(value, Decimal):
value = Decimal128(value)
elif isinstance(value, datetime.date):
return Decimal128(value)
if isinstance(value, datetime.date):
# Turn dates into datetimes since BSON doesn't support dates.
value = datetime.datetime.combine(value, datetime.datetime.min.time())
elif isinstance(value, datetime.time):
return datetime.datetime.combine(value, datetime.datetime.min.time())
if isinstance(value, datetime.time):
# Turn times into datetimes since BSON doesn't support times.
value = datetime.datetime.combine(datetime.datetime.min.date(), value)
elif isinstance(value, datetime.timedelta):
return datetime.datetime.combine(datetime.datetime.min.date(), value)
if isinstance(value, datetime.timedelta):
# DurationField stores milliseconds rather than microseconds.
value /= datetime.timedelta(milliseconds=1)
elif isinstance(value, UUID):
value = value.hex
return value / datetime.timedelta(milliseconds=1)
if isinstance(value, UUID):
return value.hex
return {"$literal": value}


Expand Down

0 comments on commit 6a97c8e

Please sign in to comment.