public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Ignore all exceptions for validates_acceptance_of columns fetch so it can run 
even without a database connection

Signed-off-by: Michael Koziarski <michael@koziarski.com>
Tarmo Tänav (author)
Fri Sep 26 10:57:56 -0700 2008
NZKoz (committer)
Fri Sep 26 11:09:39 -0700 2008
commit  ea609b265ffc30cac00bf09a262027f96964ed6f
tree    6877969d5e0394c4126e583328c2cb1ca7bd5262
parent  4d9a7ab5f5c28820e0b076f9ca44bdd20e19e6ea
...
472
473
474
475
 
476
477
478
...
472
473
474
 
475
476
477
478
0
@@ -472,7 +472,7 @@ module ActiveRecord
0
 
0
         db_cols = begin
0
           column_names
0
-        rescue ActiveRecord::StatementInvalid
0
+        rescue Exception # To ignore both statement and connection errors
0
           []
0
         end
0
         names = attr_names.reject { |name| db_cols.include?(name.to_s) }

Comments

Manfred Fri Sep 26 11:37:53 -0700 2008

I’m not sure catching Exception is such a good idea, it might mask all kinds of bugs like syntax errors thrown while executing the column_names method.

Why not just catch the errors thrown by ActiveRecord?

NZKoz Fri Sep 26 13:43:48 -0700 2008

Yeah, it’s definitely less than ideal, but the problem is the variety of exceptions that get thrown when this thing is missing. There’s one for each of the adapters, and several different ones depending on the ‘backing gem’ i.e. pg vs postgres.

Hopefully for 2.3 we can tidy the boundaries between adapter and driver and make sure that only AR errors are thrown by the Adapters, but right now that line’s too fuzzy and making a far reaching change for this one case didn’t quite seem worth it.