Treat table_exists? exceptions as an indication that the table does not exist #19

Merged
merged 3 commits into from Dec 7, 2011
Jump to file or symbol
Failed to load files and symbols.
+13 −1
Diff settings

Always

Just for now

@@ -62,7 +62,7 @@ def normalize_default_attributes
def inherited(subclass)
super
- if subclass.respond_to?(:table_exists?) && subclass.table_exists?
+ if subclass.respond_to?(:table_exists?) && (subclass.table_exists? rescue false)
subclass.normalize_default_attributes
end
end
@@ -11,4 +11,16 @@
klass.should respond_to(:normalize_attribute)
end
+ it 'should not fail due to database exceptions raised by table_exists?' do
+ class PGError < RuntimeError; end
+
+ Class.new(ActiveRecord::Base) do
+ def self.table_exists?
+ raise PGError, "FATAL: something bad happened trying to probe for table existence"
+ end
+
+ include AttributeNormalizer
+ end
+
+ end
end