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

Fixed #373 -- Added CompositeField-based Meta.primary_key. #18031

Closed

Conversation

csirmazbendeguz
Copy link

@csirmazbendeguz csirmazbendeguz commented Mar 28, 2024

Trac ticket number

ticket-373

Branch description

This branch is based on PR #17279.
See my proposal.

Code example:

class Tenant(models.Model):
    pass


class User(models.Model):
    tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE)
    id = models.SmallAutoField()

    class Meta:
        primary_key = ("tenant_id", "id")


class Comment(models.Model):
    tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE)
    id = models.SmallAutoField()
    user_id = models.SmallIntegerField()
    user = models.ForeignObject(
        User,
        on_delete=models.CASCADE,
        from_fields=("tenant_id", "user_id"),
        to_fields=("tenant_id", "id"),
        related_name="+",
    )

    class Meta:
        primary_key = ("tenant_id", "id")

@csirmazbendeguz csirmazbendeguz changed the title [WIP] Fixed #373 -- Add CompositeField-based Meta.primary_key Fixed #373 -- Add CompositeField-based Meta.primary_key Apr 1, 2024
@csirmazbendeguz
Copy link
Author

@charettes, could you give it a look? It looks like a big PR, but most of the changes are just tests.

@csirmazbendeguz csirmazbendeguz changed the title Fixed #373 -- Add CompositeField-based Meta.primary_key Fixed #373 -- Added CompositeField-based Meta.primary_key. Apr 6, 2024
@csirmazbendeguz
Copy link
Author

csirmazbendeguz commented Apr 7, 2024

I squashed all the commits in a new PR, so closing this (it was easier to open a new PR than to resolve all the conflicts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant