Skip to content

suggest-index command does not recognize some index definitions #60

Description

@sevdog

VS Code version

None

OS

Ubuntu 24.04

Steps to reproduce

The suggest-indexes command seems to not recognize the following indexes:

  • primary key, also filtering by pk= and id= (in default model configuration, without any PK ovedrride) is not recognized as the same filter (pk is just an alias of whatever the primary key field is)
  • fields with db_index=True (including foreign-keys)
  • unique fields unique=True (because a unique constraint involves an index)
  • UniqueConstraints

Sample models.py (minimized)

class AModel(models.Model):
    field = models.IntegerField()

class SimpleModel(models.Model):
    unique_field = models.IntegerField(unique=True)
    foreign_key = models.ForeignKey(AModel, db_index=True)
    other_field = models.IntegerField()

    class Meta:
        constraints = [models.UniqueConstraint(fields=('foreign_key', 'other_field'), name='uc')]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions