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

Bug report: Self foreign keys are not handled #202

Closed
norbertcyran opened this issue Jun 21, 2021 · 0 comments · Fixed by #203
Closed

Bug report: Self foreign keys are not handled #202

norbertcyran opened this issue Jun 21, 2021 · 0 comments · Fixed by #203

Comments

@norbertcyran
Copy link
Contributor

Describe the bug
After creating the migration with the model containing foreign key to itself, migration is failing due to KeyError. After quick investigation, the exact line containing the bug is ForeignKeyField(model=migrator.orm["model"], ...). During execution of this code, "model" is not yet added to migrator.orm dict. Instead, the call should look like: ForeignKeyField(model="self", ...). After changing it the proposed way, migration has completed successfully.

To Reproduce
Steps to reproduce the behavior:

  1. Write a model containing a self-referencing foreign key:
class TestModel(Model):
    parent = ForeignKeyField("self")
  1. Create a migration
  2. Run the migration

Expected behavior
Migration should pass correctly.

Desktop (please complete the following information):

  • Version 1.4.2
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 a pull request may close this issue.

1 participant