Skip to content

Conversation

csirmazbendeguz
Copy link
Contributor

@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
Contributor 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
Contributor 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

Development

Successfully merging this pull request may close these issues.

1 participant