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 PostgreSQL Cidr#change?: NoMethodError: undefined method `prefix' for nil #51758

Merged
merged 1 commit into from May 14, 2024

Conversation

taketo1113
Copy link
Contributor

@taketo1113 taketo1113 commented May 7, 2024

Motivation / Background

This Pull Request has been created because fixes an error.

Steps to reproduce are below comments.
#51633 (comment)

Detail

PostgreSQL Cidr#change? raise an error of NoMethodError: undefined method `prefix' for nil, when creating a record with an empty value of inet/cidr column.

This Pull Request changes fixes the error and adds a test case.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Comment on lines 28 to 31
assert_equal false, type.changed?(nil, nil, "")
assert_equal true, type.changed?("192.168.0.0/24", nil, "")
assert_equal true, type.changed?(nil, "192.168.0.0/24", "")
assert_equal true, type.changed?("192.168.0.0/24", "192.168.0.0/25", "")

Choose a reason for hiding this comment

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

We probably don't need to verify equality with false/true here, can we just use assert and assert_not on these, to simplify?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carlosantoniodasilva Thanks for comments.
I have fixed it.

@carlosantoniodasilva carlosantoniodasilva merged commit 0be846c into rails:main May 14, 2024
2 of 3 checks passed
carlosantoniodasilva added a commit that referenced this pull request May 14, 2024
PostgreSQL Cidr#change? raise an error of NoMethodError: undefined method `prefix' for nil, when creating a record with an empty value of inet/cidr column.
carlosantoniodasilva added a commit that referenced this pull request May 14, 2024
PostgreSQL Cidr#change? raise an error of NoMethodError: undefined method `prefix' for nil, when creating a record with an empty value of inet/cidr column.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants