Skip to content

INTPYTHON-348 Update raw_query tests for raw_mql #10

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

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a017deb
Update GenericForeignKey object_id to CharField/TextField
timgraham Jul 17, 2024
9152f83
use ObjectIdAutoField in test models
timgraham Jul 17, 2024
c565caf
update serializer output for MongoAutoField
timgraham Jul 18, 2024
36b1030
comment out usage of QuerySet.extra()
timgraham Jul 18, 2024
c09a3b8
remove unsupported usage of nulls_first
timgraham Jul 22, 2024
e124a7b
aggregation, aggregation_regress edits
timgraham Aug 19, 2024
871fa74
add test for ModelForm data using numeric pks
timgraham Aug 16, 2024
4e34ee4
drop requirement that QuerySet.explain() log a query
timgraham Aug 16, 2024
abfd5cb
schema and migrations test edits
timgraham Aug 24, 2024
b08f3f1
backends edits
timgraham Aug 29, 2024
c1627fe
introspection test edits
timgraham Aug 27, 2024
0f68e6f
Added supports_sequence_reset skip in backends tests.
timgraham Aug 23, 2024
953dbf3
remove SQL introspection from queries tests
timgraham Sep 3, 2024
26dabbb
Added QuerySet.union() test with renames.
WaVEV Sep 7, 2024
9ba649b
Fixed #35815 -- Allowed db_default to be a literal.
timgraham Oct 9, 2024
553b35d
edits for many test apps
timgraham Sep 26, 2024
b4b95ab
indexes
timgraham Oct 14, 2024
0354694
add skip for partial index support
timgraham Oct 17, 2024
aa10dfd
fix "view on site" for non-integer pks
timgraham Oct 17, 2024
0dde152
allow runtests.py to discover tests in django_mongodb/tests
timgraham Oct 22, 2024
fa62156
INTPYTHON-348 Update raw_query tests for raw_mql
aclark4life Oct 28, 2024
98a6cce
INTPYTHON-348 Update raw_query tests for raw_mql
aclark4life Nov 5, 2024
7b822c2
Revert "INTPYTHON-348 Update raw_query tests for raw_mql"
aclark4life Nov 6, 2024
4874aee
INTPYTHON-348 Update raw_query tests for raw_mql
aclark4life Nov 6, 2024
fda8f96
INTPYTHON-348 add support for QuerySet.raw()
aclark4life Nov 7, 2024
b4687dc
INTPYTHON-348 Update raw_query tests for raw_mql
aclark4life Nov 8, 2024
7a46121
INTPYTHON-348 Update raw_query tests for raw_mql
aclark4life Nov 8, 2024
65d64eb
INTPYTHON-348 Add support for QuerySet.raw()
aclark4life Nov 9, 2024
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
8 changes: 7 additions & 1 deletion tests/raw_query/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.db import models
from django_mongodb.manager import MongoManager
from django_mongodb.fields import ObjectIdAutoField


class Author(models.Model):
id = ObjectIdAutoField(primary_key=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to add an explicit primary key to all these methods. Put DEFAULT_AUTO_FIELD = "django_mongodb.fields.ObjectIdAutoField" in your test settings file.

first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
dob = models.DateField()
Expand All @@ -20,6 +22,7 @@ def __init__(self, *args, **kwargs):


class Book(models.Model):
id = ObjectIdAutoField(primary_key=True)
title = models.CharField(max_length=255)
author = models.ForeignKey(Author, models.CASCADE)
paperback = models.BooleanField(default=False)
Expand All @@ -35,17 +38,20 @@ class BookFkAsPk(models.Model):


class Coffee(models.Model):
id = ObjectIdAutoField(primary_key=True)
brand = models.CharField(max_length=255, db_column="name")
price = models.DecimalField(max_digits=10, decimal_places=2, default=0)
objects = MongoManager()


class MixedCaseIDColumn(models.Model):
id = models.AutoField(primary_key=True, db_column="MiXeD_CaSe_Id")
# id = models.AutoField(primary_key=True,
id = ObjectIdAutoField(primary_key=True, db_column="MiXeD_CaSe_Id")
objects = MongoManager()


class Reviewer(models.Model):
id = ObjectIdAutoField(primary_key=True)
reviewed = models.ManyToManyField(Book)
objects = MongoManager()

Expand Down
2 changes: 1 addition & 1 deletion tests/raw_query/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_raw_query_lazy(self):
Raw queries are lazy: they aren't actually executed until they're
iterated over.
"""
q = Author.objects.raw_mql("SELECT * FROM raw_query_author")
q = Author.objects.raw_mql([])
self.assertIsNone(q.query.cursor)
list(q)
self.assertIsNotNone(q.query.cursor)
Expand Down