I've come across a strange issue using the timestamps plugin (sequel, ruby
and postgres versions given at the bottom):
p1 = Scheduling::Period.create(description: "abc", representative_time:
tt(12,00))
p2 = Scheduling::Period.first_where(description: "abc",
representative_time: tt(12,00))
p1 == p1 #=> false
p1.values == p2.values #=> false
p1.values.each {|k, v| puts "#{k}: #{v == p2[k]}" }
id: true
created_at: true
updated_at: false
description: true
representative_time: true
notification_mode: true
current_state_id: true
p1[:updated_at] #=> Sat, 27 Jun 2015 10:13:40 -0700
p2[:updated_at] #=> Sat, 27 Jun 2015 10:13:40 -0700
p1[:updated_at].to_f #=> 1435425220.3419495
p2[:updated_at].to_f #=> 1435425220.341949
p1.reload == p2 #=> true
It appears that the database is truncating the timestamp but this
truncation isn't fed back to the model after creation.
Is this a known issue? I'm currently working around it in my tests by
reloading the model before checking equality. Is there a nicer way of
getting around the issue?
Many thanks,
Tom
=== versions ===
$ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
$ psql --version
psql (PostgreSQL) 9.4.3
$ cat Gemfile.lock | grep sequel
sequel (4.21.0)
sequel-rails (0.9.6)
sequel (>= 3.28, < 5.0)
sequel (= 4.21.0)
sequel-rails
====
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.