Skip to content

Commit

Permalink
adapt raw_query tests for QuerySet.raw_aggregate()
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Graham <[email protected]>
  • Loading branch information
aclark4life and timgraham committed Nov 21, 2024
1 parent ff43b2b commit 753ce22
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 174 deletions.
13 changes: 13 additions & 0 deletions tests/raw_query/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django_mongodb.fields import ObjectIdAutoField
from django_mongodb.managers import MongoManager

from django.db import models

Expand All @@ -8,6 +9,8 @@ class Author(models.Model):
last_name = models.CharField(max_length=255)
dob = models.DateField()

objects = MongoManager()

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Protect against annotations being passed to __init__ --
Expand All @@ -25,25 +28,35 @@ class Book(models.Model):
paperback = models.BooleanField(default=False)
opening_line = models.TextField()

objects = MongoManager()


class BookFkAsPk(models.Model):
book = models.ForeignKey(
Book, models.CASCADE, primary_key=True, db_column="not_the_default"
)

objects = MongoManager()


class Coffee(models.Model):
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 = ObjectIdAutoField(primary_key=True, db_column="MiXeD_CaSe_Id")

objects = MongoManager()


class Reviewer(models.Model):
reviewed = models.ManyToManyField(Book)

objects = MongoManager()


class FriendlyAuthor(Author):
pass
Loading

0 comments on commit 753ce22

Please sign in to comment.