Skip to content

Commit 076b76a

Browse files
committed
Add DatabaseOperations.get_hardcoded_pk() and get_nonexistent_pk()
proposed for Django 6.2
1 parent 71c489b commit 076b76a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

django_mongodb_backend/operations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import uuid
55
from decimal import Decimal
66

7-
from bson import Decimal128, Int64
7+
from bson import Decimal128, Int64, ObjectId
88
from django.conf import settings
99
from django.core.exceptions import ImproperlyConfigured
1010
from django.db import DataError, models
@@ -375,3 +375,9 @@ def format_for_duration_arithmetic(self, sql):
375375

376376
def time_trunc_sql(self, lookup_type, sql, params, tzname=None):
377377
return f"DATE_TRUNC(%s, {sql})::time", (lookup_type, *params)
378+
379+
def get_hardcoded_pk(self, value):
380+
return ObjectId(f"{value:024}")
381+
382+
def get_nonexistent_pk(self, value):
383+
return ObjectId()

0 commit comments

Comments
 (0)