Skip to content

The ForeignKey field was not generated correctly #38

@f1238762001

Description

@f1238762001

My Django code:

class Prod(Model):
  class Meta:
    db_table = 'prod'
    verbose_name = 'Prod'
    verbose_name_plural = 'Prod'
  id = AutoField(primary_key=True)
  name = CharField(max_length=40)

class TestA(Model):
  class Meta:
    db_table = 'test_a'
    verbose_name = 'TestA'
    verbose_name_plural = 'TestA'

  id = AutoField(primary_key=True)
  prod = ForeignKey(Prod, on_delete=CASCADE)
  name = CharField(max_length=40)
  ....

The generated dbml:

Table TestA {
  id auto [note: '''*id*''', pk, unique, not null]
  name char [note: '''*name*''', not null]
  ....
}
ref: prod.TestA.prod_id > prod.Prod.id

It will report the error: Column 'prod_id' does not exist in Table 'TestA '

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions