#312 √ resolved
Tony Pitale

Time type returns different time

Reported by Tony Pitale | May 26th, 2008 @ 10:14 PM

class TimeTest

include DataMapper::Resource

property :id, Integer, :key => true, :serial => true

property :created_at, Time

end

t = TimeTest.new(:created_at=Time.now)

t.save

t1 = TimeTest.first

puts t1.created_at #=> returns a completely different time & date

Using postgresql as the database and edge DM

Oddly, checking the database, the time & date are correct

Comments and changes to this ticket

  • Adam French

    Adam French June 12th, 2008 @ 03:14 PM

    • → State changed from “new” to “open”

    I can't seem to reproduce this in a spec, tony. Here's the spec I'm using

        describe '#312' do
          it "should behave sanely for time fields" do
    
            class Thing
              include DataMapper::Resource
              property :id, Integer, :serial => true
              property :created_at, Time
            end
    
            Thing.auto_migrate!(:postgres)
    
            repository(:postgres) do
              t = Thing.new
              t.created_at = Time.parse("1983-09-30 17:53")
    
              t.save
    
              t1 = Thing.first
              t1.created_at.should == t.created_at
    
            end
    
          end
        end
    
  • Tony Pitale

    Tony Pitale June 12th, 2008 @ 03:19 PM

    try Time.now, that's what I was using

    the only other thing was that the problem was fixed in the past couple weeks, which is certainly possible

  • Adam French

    Adam French June 12th, 2008 @ 04:23 PM

    Is this one better?

        describe '#312' do
          it "should behave sanely for time fields" do
    
            class Thing
              include DataMapper::Resource
              property :id, Integer, :serial => true
              property :created_at, Time
            end
    
            Thing.auto_migrate!(:postgres)
    
            repository(:postgres) do
              time_now = Time.now
                        
              t = Thing.new
              t.created_at = time_now
    
              t.save
    
              t1 = Thing.first
              t1.created_at.should == time_now
            end
    
          end
        end
    
  • Adam French
  • Bernerd Schaefer

    Bernerd Schaefer June 17th, 2008 @ 05:39 PM

    • → Milestone cleared.
    • → Assigned user changed from “Sam Smoot” to “Bernerd Schaefer”

    Are you still having the problem?

    It seems like this could be a dataobjects bug.

    What platform are you running? What version of dm/do? What version of postgres?

  • Bernerd Schaefer

    Bernerd Schaefer July 30th, 2008 @ 04:04 PM

    • → State changed from “open” to “resolved”
    • → Tag changed from “” to “bug dataobjects dm-core edge postgresql”

    Since we haven't been able to reproduce this, I'm going to mark this as resolved. If you still encounter problems with it, let me know.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins