sijms / go-ora

Pure go oracle client
MIT License
786 stars 174 forks source link

Time not in timezone #447

Closed m1k1o closed 10 months ago

m1k1o commented 11 months ago

I have been using this driver for months. But with this recent change https://github.com/sijms/go-ora/commit/c43a92b1032b9c151c4ef5b1b9c3ca0b2e9ec8fc timezone is off. It looks like oracle returns datetime in UTC and timezone, but this driver treats it as if that returned datetime was already in the specified timezone. I am using DATE WITH TIMEZONE field.

So I tried to migrate to godror and there it works fine. Removing timeInZone = true when zone == nil fixes my issue.

I think that this is a bug on this driver because I verified with the other and there it works.

sijms commented 11 months ago

would you please give an example code to produce the error

zura101 commented 11 months ago

I have used test case described in #422

go result

{                                                            
  "CurrentDate": "2023-10-09 17:09:00",                      
  "CurrentTimestamp": "2023-10-09 17:09:00 +04:00",          
  "Sysdate": "2023-10-09 17:09:00",                          
  "Systimestamp": "2023-10-09 17:09:00 +04:00",              
  "TimeCurrentDate": "2023-10-09T17:09:00+04:00",            
  "TimeCurrentTimestamp": "2023-10-09T13:09:00.322788+04:00",
  "TimeSysdate": "2023-10-09T17:09:00+04:00",                
  "TimeSystimestamp": "2023-10-09T13:09:00.322787+04:00"     
}                                                            
         Sysdate: Mon Oct  9 17:09:00 +04:00 2023
    Systimestamp: Mon Oct  9 13:09:00 +04:00 2023
       Real Time: Mon Oct  9 17:08:59 +04 2023   

jetbrains datagrip result

CURRENT_DATE,2023-10-09 13:09:22
CURRENT_TIMESTAMP,2023-10-09 13:09:22 UTC
SYSDATE,2023-10-09 17:09:22
SYSTIMESTAMP,2023-10-09 17:09:22 +04:00
T_CURRENT_DATE,2023-10-09 13:09:22
T_CURRENT_TIMESTAMP,2023-10-09 13:09:22.911876 +00:00
T_SYSDATE,2023-10-09 17:09:22
T_SYSTIMESTAMP,2023-10-09 17:09:22.911873 +04:00

issue is partially similar.

unlike #422, TimeSysdate is showing correct time and zone, but TimeSystimestamp is the right zone, but the wrong time.

I am using go 1.20 and go-ora v2.7.19

m1k1o commented 10 months ago

I tried with Oracle 12 and the new flow actually works. But with Oracle 19 it returns the right zone, but the wrong time.

vivi-ui commented 10 months ago

use: TIMESTAMP WITH LOCAL TIME ZONE is ok

m1k1o commented 10 months ago

@vivi-ui no change, still wrong time even with TIMESTAMP WITH LOCAL TIME ZONE and still correct with godror.

sijms commented 10 months ago

sorry for late replay I fix it in next release you can test it go.mod require github.com/sijms/go-ora/v2 v2.7.20-0.20231110222249-d97857c0676a

sijms commented 10 months ago

fixed in v2.7.20