Skip to content

Cast query_cache value when using URL configuration #53491

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

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

zzak
Copy link
Member

@zzak zzak commented Oct 29, 2024

When using DATABASE_URL, you cannot adjust the max size of the query_cache using the parameter. Since it remains as the string "42" it will result in not setting a max size:

case query_cache = db_config&.query_cache
when 0, false
nil
when Integer
query_cache
when nil
DEFAULT_SIZE
end

cc @byroot

Comment on lines 85 to 92
case value = configuration_hash[:query_cache]
when /\A\d+\z/
value.to_i
when "false"
false
else
value
end
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be in the subclass, UrlConfig, as it doesn't make sense to do casting when provided a hash from Ruby.

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, yeah forgot we talked about this. Fixed in 6302519.

@zzak zzak force-pushed the query_cache-url_config branch from c26781d to 6302519 Compare October 30, 2024 09:45
@@ -57,6 +57,17 @@ def initialize(env_name, name, url, configuration_hash = {})
@configuration_hash.freeze
end

def query_cache # :nodoc:
case value = configuration_hash[:query_cache]
Copy link
Member

Choose a reason for hiding this comment

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

I think we might want to do this in initialize so that we don't redo it on every access.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I didn't realize that was already happening for "false". Added 15606ec.

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops fixed tests in af9b0f2

@zzak zzak force-pushed the query_cache-url_config branch from 6302519 to 15606ec Compare October 30, 2024 12:09
@zzak zzak force-pushed the query_cache-url_config branch from 15606ec to af9b0f2 Compare October 30, 2024 12:30
@byroot byroot merged commit a807d58 into rails:main Oct 30, 2024
3 checks passed
@zzak zzak deleted the query_cache-url_config branch October 30, 2024 12:48
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.

2 participants