Thank you Jeremy!
And thank you for your swift response - much appreciated.

On 2020/03/22 17:57, Jeremy Evans wrote:
On Saturday, March 21, 2020 at 11:46:35 PM UTC-7, James Silberbauer wrote:

    I've just updated Sequel from 5.21.0 to 5.30.0 and now can't read
    a row that includes a timestamp value when application_timezone is
    set to :local.

    Here's an illustration using this test table:
         Table "public.test_time"
      Column   |           Type |                       Modifiers
    
-----------+--------------------------+--------------------------------------------------------
     id        | integer                  | not null default
    nextval('test_time_id_seq'::regclass)
     some_text | character varying(255)   | not null
     some_time | timestamp with time zone | not null
    Indexes:
        "test_time_pkey" PRIMARY KEY, btree (id)

    $ pry
    [1] pry(main)> require 'sequel'
    => true
    [2] pry(main)> require 'pg'
    => true
    [3] pry(main)> DB = Sequel.connect(db_path)
    => #<Sequel::Postgres::Database: "xxx">
    [4] pry(main)> DB[:test_time].insert(some_text: 'first',
    some_time: Time.now)
    => 1
    [5] pry(main)> DB[:test_time].all
    => [{:id=>1, :some_text=>"first", :some_time=>2020-03-22 08:24:22
    +0200}]
    [6] pry(main)> Sequel.application_timezone = :local
    => :local
    [7] pry(main)> Sequel.database_timezone = :utc
    => :utc
    [8] pry(main)> DB[:test_time].insert(some_text: 'second',
    some_time: Time.now)
    => 2
    [9] pry(main)> DB[:test_time].where(id: 2).first
    NoMethodError: undefined method `local' for 2020-03-22 08:25:22
    +0200:Time
    Did you mean?  localtime
    from
    
/home/james/.gem/ruby/2.5.5/gems/sequel-5.30.0/lib/sequel/adapters/postgres.rb:614:in
    `yield_hash_rows'


    Using Sequel 5.30.0, pg 1.2.3, ruby 2.5.5, postgresql 9.5.19,
    Ubuntu 16.04, timezone SAST (+2hr).

    $ timedatectl
          Local time: Sun 2020-03-22 08:44:14 SAST
      Universal time: Sun 2020-03-22 06:44:14 UTC
            RTC time: Sun 2020-03-22 06:44:14
           Time zone: Africa/Johannesburg (SAST, +0200)
     Network time on: yes
    NTP synchronized: yes
     RTC in local TZ: no


    Any insight would be appreciated.
    James


Thanks for reporting this.  This is a bug in sequel_pg's handling of timestamptz types when setting local application timezone and utc database timezone, by calling the wrong method (local is the class method, localtime is the instance method).  It was introduced in the performance improvements in sequel_pg 1.10.0.  This should have been caught earlier by the tests, but the tests don't test timestamptz types by default (you need to set the SEQUEL_PG_TIMESTAMPTZ environment variable when testing). I guess I hadn't added that to my pre-release test matrix, and that's why I missed this.  I fixed this (https://github.com/jeremyevans/sequel_pg/commit/85b791ca9753083a208d6198935dd7ddd8e81527) and will release a new sequel_pg gem tomorrow.  I'll also take another look at my pre-release test matrix and make sure it includes these tests in the future to prevent regressions.

Thanks,
Jeremy
--
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] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/6772ea3e-a5fc-4e72-9c84-2d2b0f7116cd%40googlegroups.com <https://groups.google.com/d/msgid/sequel-talk/6772ea3e-a5fc-4e72-9c84-2d2b0f7116cd%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/39383bc8-6be2-c5a6-ff8e-bd01a5e9e3f9%40telkomsa.net.

Reply via email to