Skip to content

Junie inspectdb creates a redundant unique_together for composite primary keys #3

@AlexanderPrendota

Description

@AlexanderPrendota

Description
With the following table:

CREATE TABLE example (
a integer,
b integer,
c integer,
PRIMARY KEY (a, c)
);
Running inspectdb produces the following model definition:

class Example(models.Model):
pk = models.CompositePrimaryKey('a', 'c')
a = models.IntegerField()
b = models.IntegerField(blank=True, null=True)
c = models.IntegerField()

class Meta:
    managed = False
    db_table = 'example'
    unique_together = (('a', 'c'),)

I'm pretty sure the last unique_together = (('a', 'c'),) is redundant since the pk = models.CompositePrimaryKey('a', 'c') already implies uniqueness, no?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions