Skip to content
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

Add test reproducing foreign key related manager failure #300

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions test-data/typecheck/fields/test_related.yml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,37 @@
pass


- case: test_foreign_key_from_subclass_gets_set_up_correctly
main: |
from myapp import models
installed_apps:
- myapp
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from __future__ import annotations
from django.db import models

class BaseInvoice(models.Model):
class Meta:
abstract = True
ordering = ['-created_at']

def process(self, invoice: Invoice):
reveal_type(invoice.invoicerow_set) # N: Revealed type is 'django.db.models.manager.RelatedManager[myapp.models.InvoiceRow]'

class Invoice(BaseInvoice):
pass

class BaseRow(models.Model):
class Meta:
abstract = True
ordering = ['-created_at']

class InvoiceRow(BaseRow):
invoice = models.ForeignKey(Invoice, null=False, on_delete=models.CASCADE)

- case: foreign_key_relationship_for_models_with_custom_manager
main: |
from myapp.models import Transaction
Expand Down