Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ActiveRecord#method_missing odd behavior #10936

Closed
jmazzi opened this Issue Jun 13, 2013 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

jmazzi commented Jun 13, 2013

There was an issue filed about a bug that caused RSpec to exit with 0 on an exception. The bug has since been filed upstream with ruby-lang.

The odd part about this issue is that I was only able to trigger it when ActiveRecord#method_missing was called. The details on how to do that are in rspec/rspec-core#928. Ub that issue, @alindeman said:

I think there's also reason to think it's buggy for ActiveRecord to add an inspect method to the model class that raises an exception when the database is unavailable.`.

Can anyone confirm that this is the intended behavior?

Member

senny commented Jun 19, 2013

@jmazzi what version of Active Record are you referring to? With Rails 4 ActiveRecord::Base.inspect works without a database:

$ bin/rails c
Loading development environment (Rails 4.1.0.beta)
irb(main):001:0> User.inspect
=> "User(Table doesn't exist)"
Contributor

alindeman commented Jun 19, 2013

That's without a table; the issue we saw was when the database didn't exist.

Member

senny commented Jun 19, 2013

@alindeman my example was with a sqlite3 connection and I removed the database before starting the console, so there was no database available.

Contributor

alindeman commented Jun 19, 2013

Can you reproduce it if you use MySQL or Postgres? That's what we were using.

Member

senny commented Jun 19, 2013

postgresql

Loading development environment (Rails 4.1.0.beta)
irb(main):001:0> User
PG::Error: FATAL:  database "i_do_not_exist" does not exist

mysql

irb(main):001:0> User
Mysql2::Error: Access denied for user 'myuser'@'localhost' (using password: YES)

I'll take a look.

Member

senny commented Jun 19, 2013

I submitted a PR to prevent mysql and postgres to raise on inspect: #11014

@drogus drogus closed this in #11014 Jun 21, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment