Skip to content

remove test_filter_reverse_non_integer_pk from expected failures #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

timgraham
Copy link
Collaborator

This test required microsecond support and has been fixed on the Django fork:

diff --git a/tests/queries/models.py b/tests/queries/models.py
index 9f4cf040b6..546f9fad5b 100644
--- a/tests/queries/models.py
+++ b/tests/queries/models.py
@@ -4,7 +4,7 @@ Various complex queries that have been problematic in the past.
 
 import datetime
 
-from django.db import models
+from django.db import connection, models
 from django.db.models.functions import Now
 
 
@@ -66,8 +66,17 @@ class Annotation(models.Model):
         return self.name
 
 
+def now():
+    value = datetime.datetime.now()
+    return (
+        value
+        if connection.features.supports_microsecond_precision
+        else value.replace(microsecond=0)
+    )
+
+
 class DateTimePK(models.Model):
-    date = models.DateTimeField(primary_key=True, default=datetime.datetime.now)
+    date = models.DateTimeField(primary_key=True, default=now)
 
     class Meta:
         ordering = ["date"]

This test required microsecond support and has been fixed on the Django fork.
@timgraham timgraham requested a review from WaVEV July 25, 2024 12:30
@timgraham timgraham merged commit 8bc7160 into mongodb:main Jul 25, 2024
3 checks passed
@timgraham timgraham deleted the test_filter_reverse_non_integer_pk branch July 25, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants