added :ignore_database_name option#357
Conversation
when enabled, it won't write the database name to the annotatino block this option may be confusing in a sharded database scenario, where the development name just does not map to reality
drwl
left a comment
There was a problem hiding this comment.
Thanks for the PR and the explanation 👍
|
Thank you for the PR! Sorry for the delayed reply. Is this for a multi-db environment? If so, there is already an ( Also, having an option that isn't very visible / is easy to miss feels like something we should fix. ) |
|
@OdenTakashi our setup is not for multi database, just sharded. I had tried I also think that it's quite common to name your database differently per environment ("${name}_production" for example), so having it pop up in annotations gets confusing, hence why I think this option is justified. We were previously using |
|
@HoneyryderChuck Thanks for the clarification — I overlooked that your setup is sharded rather than multi-database. Sorry about that. I tried this locally with a sharded configuration and confirmed that the database name is included there as well. In my test, setting This is also the only place where database_name = @model.database_name if multi_db_environment?
# ...
def multi_db_environment?
return false if @options[:ignore_multi_database_name]
if defined?(::Rails) && ::Rails.env
ActiveRecord::Base.configurations.configs_for(env_name: ::Rails.env).size > 1
else
false
end
endThat said, the name Thanks again for the clarification — this was a helpful insight. |
|
@OdenTakashi Thank you for looking deeper into this. I should have looked at the existing options to see if there was any pre-existing behavior, so thanks for catching that. |
|
@OdenTakashi just a clarification that the development config ain't sharded, which is probably why the multi db option didn't catch it. And we annotate in development. |
|
@HoneyryderChuck I want to make sure I understand what happened correctly: in development, where the configuration uses neither multiple databases nor sharding, was the database name still included in the annotation even with I’m curious about what caused that, since If you have a minimal reproduction, it would be helpful if you could share it. |
|
@OdenTakashi my bad, turns out the issue was in the config file on my side ( |
|
@HoneyryderChuck Thanks for checking and confirming! That makes sense — I’m glad to hear that Since Since some users may already rely on |
when enabled, it won't write the database name to the annotatino block
this option may be confusing in a sharded database scenario, where the development name just does not map to reality