Skip to content

timezone conversion execute_procedure versus select_all (@4.2.6) #449

@krzcho

Description

@krzcho

I have inconsistency: when procedure is returning dates they are treated using local system timezone while using select_all method it is treated as UTC (which correct and expected)
Am I missing something? I would except all adapter data retrieval methods behave the same way

CREATE PROC dbo.test AS
SELECT GETUTCDATE() utcdate

irb(main):041:0> ActiveRecord::Base.execute_procedure("test")[0]["utcdate"].zone
  Execute Procedure (0.0ms)  EXEC test
=> "Middle East Standard Time"

irb(main):040:0> ActiveRecord::Base.connection.select_all("select getutcdate()".force_encoding("utf-8"))[0]["utcdate"].zone
   (0.0ms)  EXEC sp_executesql N'select getutcdate() as utcdate'
=> "UTC"

irb(main):001:0> TinyTds::Client.default_query_options
=> {:as=>:hash, :symbolize_keys=>false, :cache_rows=>true, :timezone=>:local, :empty_sets=>true}
updating timezone from local to utc solves the problem but I am not sure if it should not be set by the adapter itself to be consistent

the same issue is here #266
but I must say that ActiveRecord's timezone is left at utc so it is somehow not being propagated lower into execute_procedure tiny_tds query...

I am using tiny_tds 0.7.0, I am aware of 0.9.5 being close, maybe it will solve this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions