go-ora icon indicating copy to clipboard operation
go-ora copied to clipboard

go-ora and time.Time{} changes from v2.7.24 to v2.7.25

Open wafflze opened this issue 8 months ago • 0 comments

I am researching a potential issue created (or maybe solved) when going from go-ora version 2.7.24 to any version greater than that.

Currently, I believe the issue is related to the following (commit af8147991e2a9882258b6f3226284df56df2724a):

Version 2.7.25

  • ~~Added feature that enables the driver to read Oracle 23c wallet~~
  • Introduced passing time.Time{} for DATE, TIMESTAMP, and TIMESTAMP WITH TIMEZONE data types, so there is no need for go_ora.TimeStamp and go_ora.TimeStampTZ custom types, and they will be deprecated.
  • ~~Other bug fixes~~

I have a table with a single DATE type column:

-- Create table
create table MyTable
(
  current_date DATE
);

Prior to version 2.7.24, we could simply write:

var t time.Time
expectedtopass := time.Date(2023, 12, 31, 0, 0, 0, 0, time.Local)
if err := p.odb.FetchOne("select current_date from MyTable where current_date = :1", []interface{}{expectedtopass}, &t); err != nil {
    return err
}

and get the expected result.

However, since the changes that took place in version 2.7.25 and later, we have to modify our select statements to look like the following: TO_DATE(TO_CHAR(:1, 'YYYY-MM-DD'), 'YYYY-MM-DD'). This is a problem because we have hundreds of queries that would need to be modified:

var t time.Time
expectedtopass := time.Date(2023, 12, 31, 0, 0, 0, 0, time.Local)
if err := p.odb.FetchOne("select current_date from MyTable where current_date = TO_DATE(TO_CHAR(:1, 'YYYY-MM-DD'), 'YYYY-MM-DD')", []interface{}{expectedtopass}, &t); err != nil {
    return err
}

Without rolling back to versions prior to 2.7.24, how would you recommend addressing this? One of the reasons for the need to update our dependencies is to stay ahead of security scans in our pipelines.

wafflze avatar Jun 24 '24 13:06 wafflze