0
votes

I got stuck with some strange behavior of DataMapper's DateTime property.

Here's a simple code:

DataMapper.setup(:default, 'sqlite::/path/to/some/file.db')

class Event
  include DataMapper::Resource

  property :id, Serial
  property :time, DateTime

end

I create one item:

e = Event.new
e.time = Time.now
e.save

And now strange things happen: Time before save is ok. In the database file time is also ok.

puts e.time.to_s 
# 2011-05-01T22:38:49+02:00

But then I'm getting DateTime without "time" part.

puts Event.first.time.to_s 
# 2011-05-01T00:00:00+02:00

Any ideas?

1

1 Answers

1
votes

Unfortunately you've hit a bug in latest DataObjects. It will be fixed in next version, there's already a pull request that fixes the bug: https://github.com/datamapper/do/pull/9