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 incorrect caching of case-insensitivity #46568

Closed
wants to merge 1 commit into from

Conversation

pirj
Copy link
Contributor

@pirj pirj commented Nov 24, 2022

Motivation / Background

This Pull Request has been created to prevent multiple queries checking column insensitive comparison capability.

Detail

false values would not cache with ||=, and begin would run each time.
Instead, checking if a key for a certain column is present in the cache prevents running the query again.

Checklist

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.
  • CI is passing.

@pirj pirj force-pushed the avoid-multiple-case-insensitive-checks branch from 4714d66 to be318ae Compare November 24, 2022 19:21
@pirj pirj force-pushed the avoid-multiple-case-insensitive-checks branch 3 times, most recently from 1425457 to 1742fd4 Compare November 25, 2022 07:10
@pirj pirj requested a review from byroot November 25, 2022 07:10
Comment on lines +1035 to +1036
@case_insensitive_cache[column.sql_type] =
@case_insensitive_cache.fetch(column.sql_type) do
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@case_insensitive_cache[column.sql_type] =
@case_insensitive_cache.fetch(column.sql_type) do
@case_insensitive_cache.fetch(column.sql_type) do
@case_insensitive_cache[column.sql_type] =

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something fishy is going on here.

With this suggested change, we're basically getting rid of a redundant c[t] = c[t] when there's a t key in c already.

I'm uncertain if the same conditions as in "do not modify the array during iteration" apply here, but I'd rather keep on the safe side.

I'll revert this change if you don't object.

Copy link
Member

Choose a reason for hiding this comment

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

No it should be fine. I can have a look at the CI failure in a bit.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I think it's missing a begin/end

@byroot
Copy link
Member

byroot commented Nov 25, 2022

The code looks correct to me now, please squash the two commits though.

However I need to have a look at that CI failure, I don't know 100% it's unrelated.

@pirj pirj force-pushed the avoid-multiple-case-insensitive-checks branch from d491de6 to 1742fd4 Compare November 25, 2022 07:35
`false` values would not cache with `||=`, and `begin` would run each time.
@pirj pirj force-pushed the avoid-multiple-case-insensitive-checks branch from 1742fd4 to 6eb54a0 Compare November 25, 2022 07:40
byroot added a commit that referenced this pull request Nov 25, 2022
…hecks

Fix incorrect caching of case-insensitivity
@byroot
Copy link
Member

byroot commented Nov 25, 2022

Manually merged as b39050e.

Thanks.

@byroot byroot closed this Nov 25, 2022
@pirj pirj deleted the avoid-multiple-case-insensitive-checks branch November 25, 2022 14:07
@pirj
Copy link
Contributor Author

pirj commented Nov 25, 2022

Thank you, @byroot !

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