Permalink
Browse files

returning undefined for unknown column types

  • Loading branch information...
1 parent 206ec83 commit f0139a16c263ba62e7e45d462a4fff411ebf2523 @tenderlove tenderlove committed Nov 16, 2010
Showing with 13 additions and 7 deletions.
  1. +1 −1 lib/arel/attributes.rb
  2. +7 −6 lib/arel/attributes/attribute.rb
  3. +5 −0 test/test_attributes.rb
View
@@ -13,7 +13,7 @@ def self.for column
when :date, :datetime, :timestamp, :time then Time
when :boolean then Boolean
else
- raise NotImplementedError, "Column type `#{column.type}` is not currently handled"
+ Undefined
end
end
end
@@ -5,12 +5,13 @@ class Attribute < Struct.new :relation, :name, :column
include Arel::Predications
end
- class String < Attribute; end
- class Time < Attribute; end
- class Boolean < Attribute; end
- class Decimal < Attribute; end
- class Float < Attribute; end
- class Integer < Attribute; end
+ class String < Attribute; end
+ class Time < Attribute; end
+ class Boolean < Attribute; end
+ class Decimal < Attribute; end
+ class Float < Attribute; end
+ class Integer < Attribute; end
+ class Undefined < Attribute; end
end
Attribute = Attributes::Attribute
View
@@ -3,6 +3,11 @@
module Arel
describe 'Attributes' do
describe 'for' do
+ it 'deals with unknown column types' do
+ column = Struct.new(:type).new :crazy
+ Attributes.for(column).must_equal Attributes::Undefined
+ end
+
it 'returns the correct constant for strings' do
[:string, :text, :binary].each do |type|
column = Struct.new(:type).new type

0 comments on commit f0139a1

Please sign in to comment.