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 #47] add_reference_concurrently not checking for mismatching types #48

Conversation

joshuay03
Copy link
Contributor

@joshuay03 joshuay03 commented Feb 23, 2024

Fixes #47

The issue was that add_reference_concurrently did not have its commands checked. I've now sent it through the same checker for add_reference while ensuring the bad index check always passes.

@fatkodima fatkodima force-pushed the mismatched-types-not-working-with-add-reference-concurrently branch from 79f3571 to f24e372 Compare February 24, 2024 10:44
@fatkodima fatkodima merged commit 730b8a3 into fatkodima:master Feb 24, 2024
5 checks passed
@fatkodima
Copy link
Owner

Thank you! ❤️

Let me know if you need a new release.

@joshuay03 joshuay03 deleted the mismatched-types-not-working-with-add-reference-concurrently branch February 24, 2024 22:32
@ghiculescu
Copy link
Contributor

@fatkodima sort of related to this, do you have any views on making check_mismatched_foreign_key_type work in one direction only? For example:

  • You have a "customers" table that has as an int ID column.
  • You are creating a new table with an FK to "customers". You make customers_id a bigint.
  • At the moment check_mismatched_foreign_key_type will raise an error.

Unless there's some postgres behaviour I'm not aware of that would break it, I think this behaviour should be supported. Assuming you know that customers has the wrong ID type (if this gem doesn't already, we should think of ways to alert you about that), there's no reason to force into using the wrong column type in other places as well.

The inverse case (customers is bigint; your new FK is int) should not be allowed.

@fatkodima
Copy link
Owner

I think the gem can just implicitly ignore the cases when we add a bigint foreign key referencing the integer primary key.
I will implement this in a couple of next days or feel free to send a PR, if you would like.

@joshuay03
Copy link
Contributor Author

joshuay03 commented Feb 26, 2024

I think the gem can just implicitly ignore the cases when we add a bigint foreign key referencing the integer primary key. I will implement this in a couple of next days or feel free to send a PR, if you would like.

Got this up: #49

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.

add_reference_concurrently doesn't check for mismatching reference column types
3 participants