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

ServerSettings.databases.find時の挙動 #1

Open
w1mvy opened this issue Oct 5, 2015 · 0 comments
Open

ServerSettings.databases.find時の挙動 #1

w1mvy opened this issue Oct 5, 2015 · 0 comments

Comments

@w1mvy
Copy link
Contributor

w1mvy commented Oct 5, 2015

ServerSettings.databases.find では、name 比較で最初に引っ掛けた設定を取得する

ref: https://github.com/monsterstrike/server_settings/blob/master/lib/server_settings/role_db.rb#L20


---
databases:
  :adapter: mysql2
  :encoding: utf8
  :reconnect: true
  :database: test
  :pool: 5
  :master: localhost
  grouping:
    hoge:
      :database: grouping_hoge
      :master: localhost
  hoge:
    :database: hoge
    :master: localhost

そのため、上記のような設定の場合、 hoge の設定を find しようとすると grouping された方の hoge の設定を取得できてしまう。

irb(main):002:0> require 'server_settings'
=> true
irb(main):003:0> ServerSettings.load_config './config/servers/test/databases.yml'
=> 2015-10-08 11:35:14 +0900
irb(main):004:0> ServerSettings.databases.find 'hoge'
=> #<ServerSettings::Database:0x007fcaa52c8ec8 @name="hoge", @group="grouping", @master="localhost", @backup=nil, @slaves=nil, @settings={:adapter=>"mysql2", :encoding=>"utf8", :reconnect=>true, :database=>"grouping_hoge", :pool=>5}>

yamlの記述によっては、意図しない設定を取得する可能性があるので group 側も設定できるように変更する必要がありそう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant