plentz / lol_dba

lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
1.59k stars 69 forks source link

Exception: comparison of Symbol with String failed #66

Closed RST-J closed 8 years ago

RST-J commented 9 years ago

In some class I have an HABTM association defined where the foreign key is given as symbol which leads to the exception in the title. Changing the symbol to a string fixes this issue, so there probably is some to_s missing somewhere.

has_and_belongs_to_many :teams, association_foreign_key: :circle_id is bad has_and_belongs_to_many :teams, association_foreign_key: 'circle_id' is fine

plentz commented 9 years ago

@RST-J can you paste the exception that's being thrown? :)

RST-J commented 9 years ago
Class: Partnership
Association type: has_and_belongs_to_many
Association options: {:association_foreign_key=>:circle_id, :join_table=>"partnerships_teams"}
Exception: comparison of Symbol with String failed
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:115:in `sort'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:115:in `block (2 levels) in check_for_indexes'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:92:in `each_pair'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:92:in `block in check_for_indexes'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:86:in `each'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:86:in `check_for_indexes'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba.rb:179:in `simple_migration'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba/cli.rb:29:in `start'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/lib/lol_dba/cli.rb:17:in `start'
/home/jonas/.rvm/gems/ruby-2.2.3/gems/lol_dba-2.0.1/bin/lol_dba:10:in `<top (required)>'
/home/jonas/.rvm/gems/ruby-2.2.3/bin/lol_dba:23:in `load'
/home/jonas/.rvm/gems/ruby-2.2.3/bin/lol_dba:23:in `<main>'
/home/jonas/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
/home/jonas/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
plentz commented 8 years ago

@RST-J I've just released 2.0.3 that should fix this problem :)

thanks for the report :)