From d436116300ae554956064aef3b4b7f9c3ab32db7 Mon Sep 17 00:00:00 2001 From: John Nunemaker Date: Sat, 27 Jun 2009 00:23:19 -0400 Subject: [PATCH] Removed Date as a key type as it is not supported by the mongo ruby driver currently. Should probably just map it to time so it can still be used. --- lib/mongomapper/key.rb | 6 +++--- test/test_key.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/mongomapper/key.rb b/lib/mongomapper/key.rb index eeda205d3..eed485d74 100644 --- a/lib/mongomapper/key.rb +++ b/lib/mongomapper/key.rb @@ -2,8 +2,8 @@ class Boolean; end module MongoMapper class Key - # DateTime currently is not supported by mongo's bson so just use Time - NativeTypes = [String, Float, Time, Date, Integer, Boolean, Array, Hash] + # DateTime and Date are currently not supported by mongo's bson so just use Time + NativeTypes = [String, Float, Time, Integer, Boolean, Array, Hash] attr_accessor :name, :type, :options, :default_value @@ -49,7 +49,7 @@ def typecast(value) elsif type == Float then value.to_f elsif type == Array then value.to_a elsif type == Time then Time.parse(value.to_s) - elsif type == Date then Date.parse(value.to_s) + #elsif type == Date then Date.parse(value.to_s) elsif type == Boolean then ['true', 't', '1'].include?(value.to_s.downcase) elsif type == Integer # ganked from datamapper diff --git a/test/test_key.rb b/test/test_key.rb index 3de5457b4..1d3b1c830 100644 --- a/test/test_key.rb +++ b/test/test_key.rb @@ -14,7 +14,7 @@ class KeyTest < Test::Unit::TestCase context "The Key Class" do should "have the native types defined" do - Key::NativeTypes.should == [String, Float, Time, Date, Integer, Boolean, Array, Hash] + Key::NativeTypes.should == [String, Float, Time, Integer, Boolean, Array, Hash] end end @@ -97,7 +97,7 @@ class KeyTest < Test::Unit::TestCase key.set('2000-01-01 01:01:01.123456').should == Time.local(2000, 1, 1, 1, 1, 1, 123456) end - should "correctly typecast Dates" do + should_eventually "correctly typecast Dates" do key = Key.new(:foo, Date) key.set('2000-01-01').should == Date.new(2000, 1, 1) end