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

Cleaned up test that was missing regex escaping #49345

Merged

Conversation

aidanharan
Copy link
Contributor

Motivation / Background

Test in activerecord/test/cases/associations/eager_test.rb is missing regular expression escaping. This causes issues for other adapters such as the SQL Server Active Record adapter (https://github.com/rails-sqlserver/activerecord-sqlserver-adapter) where quoted table/column names use square brackets (eg: "[posts].[id]").

Also, removed the adapter check and allowed the adapter to quote the table-column instead.

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated 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.

@aidanharan aidanharan changed the title Regex escape the table columns in query Cleaned up test that was missing regex escaping Sep 21, 2023
else
assert_match(/WHERE "sharded_comments"."blog_id" IN \(.+\) AND "sharded_comments"."blog_post_id" IN \(.+\)/, sql)
end
c = Sharded::BlogPost.connection

Choose a reason for hiding this comment

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

Can we call this connection? Not sure the single letter / short variable name is of much help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following the convention used in other tests like https://github.com/rails/rails/blob/d56db8ff17cfdff94954e4b93b965e929df0ee63/activerecord/test/cases/batches_test.rb#L517C7-L517C7

I will change it to connection if needed.

Copy link
Member

Choose a reason for hiding this comment

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

Cool, that's fine then. I looked at this one but hadn't checked other files. Thanks!

@carlosantoniodasilva carlosantoniodasilva merged commit 585e0ca into rails:main Sep 21, 2023
4 checks passed
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