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

Fix: fix constraint creation using the wrong table and column name #118

Closed
wants to merge 1 commit into from

Conversation

BlueMagma2
Copy link

@BlueMagma2 BlueMagma2 commented Feb 6, 2024

Subject: Fix a bug regarding foreign key constraint creation

Feature or Bugfix

  • Bugfix

Detail

  • This was causing issue if a foreign key was pointing to another field than the remote table id

eg.

Table1(models.Model):
    remote_column = models.IntegerField(unique=True)

Table2(models.Model):
    local_column = models.ForeignKey(to=Table1, to_field='remote_column')

During the migrations, you would get an error saying Table2 doesn't have a column named remote_column which is absurd since that colum is not supposed to be in that table.

This was causing issue if a foreign key was pointing to another field than the remote table id
@BlueMagma2
Copy link
Author

@shimizukawa I see you merged the last PR, though I admit it was some time ago. Can you have a look ?

PS: I apologise for pinging you if you are the wrong person to address this

Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@BlueMagma2 I'm sorry for the late confirmation.
I created a another PR #139 to resolve conflict and adding tests.
Thanks for your contribution!

shimizukawa added a commit that referenced this pull request Jul 23, 2024
shimizukawa added a commit that referenced this pull request Jul 23, 2024
[#118] Fix: fix constraint creation using the wrong table and column name
@BlueMagma2
Copy link
Author

Ha cool, I'm happy to see this was merged, thanks you

@BlueMagma2 BlueMagma2 deleted the fix/fk_constraint branch August 1, 2024 13:45
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.

2 participants