Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Time datatype retrieval error #18

Open
robfors opened this issue Jan 2, 2016 · 0 comments
Open

Time datatype retrieval error #18

robfors opened this issue Jan 2, 2016 · 0 comments

Comments

@robfors
Copy link

robfors commented Jan 2, 2016

Hello, I discovered a bug when retrieving records with a Time property saved with a certain value.

Versions:

ruby-2.2.1

data_mapper (1.2.0)
data_objects (0.10.16)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.1)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-serializer (1.2.2)
dm-sqlite-adapter (1.2.0)
dm-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.2)
dm-validations (1.2.0)
do_sqlite3 (0.10.16)

To reproduce:

require 'time'
require 'data_mapper'

DataMapper.setup(:default, 'sqlite::memory:')

class Song
  include DataMapper::Resource

  property :id, Serial
  property :time, Time, :required => true
end

DataMapper.finalize
DataMapper.auto_upgrade!

t = Time.parse("2016-01-01 00:00:00.00005000 -05:00")
Song.create(time: t)
Song.at(0) # works

t = Time.parse("2016-01-01 00:00:00.00000000 -05:00") # no problems with this object
Song.create(time: t) # saves with no problems
Song.at(1) #  # will raise error here

Error returned:

/home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:153:in `local': argument out of range (ArgumentError)
    from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:153:in `next!'
    from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:153:in `block in read'
    from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
    from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:141:in `read'
    from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-core-1.2.1/lib/dm-core/repository.rb:162:in `read'
    from /home/rob/.rvm/gems/ruby-2.2.1/gems/dm-core-1.2.1/lib/dm-core/model.rb:378:in `first'
    from main.rb:18:in `<main>'

Note: changing column to DateTime later, allows me to access the values

  property :time, DateTime, :required => true 
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant