Skip to content

Commit d6fe1d4

Browse files
authored
Merge pull request #49 from hymkor/push-tzvyrnonquwn
Fix Oracle DATE/TIMESTAMP timezone handling regressions
2 parents 2e0a5e7 + e09fd3c commit d6fe1d4

6 files changed

Lines changed: 28 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Changelog (English)
66
The version string is now updated via make bump during the release process. (#46)
77
- Rename release note files to CHANGELOG.md and CHANGELOG\_ja.md. (#47)
88
- Update dependencies to the last versions compatible with Go 1.20.14 (#48)
9+
- Fixed an issue where updates to Oracle tables could affect zero rows because datetime values retrieved without timezone information failed to match in WHERE clauses. (#49)
10+
- go-ora v2.9.0 changed DATE/TIMESTAMP timezone handling, which broke datetime comparisons used by SQL-Bless updates. The Oracle driver version has been pinned to v2.8.22 for compatibility. (#49)
911

1012
v0.27.4
1113
-------

CHANGELOG_ja.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Changelog (Japanese)
66
今後、バージョンアップ時に make bump を実行する (#46)
77
- リリースノートのファイルを CHANGELOG.md と CHANGELOG\_ja.md へリネーム (#47)
88
- Go 1.20.14 でビルド可能な最後のバージョンへ依存ライブラリを更新 (#48)
9+
- edit文で、Oracle のテーブルを更新しようとした時、timezone 情報が空で取得される日時カラムの照合失敗が原因で、更新が0件になってしまう不具合を修正 (#49)
10+
- go-ora v2.9.0 で DATE/TIMESTAMP の timezone の扱いが変更され、SQL-Bless で使われている日時の比較が壊れてしまった。そのため、Oracle ドライバーのバージョンを v2.8.22 へ固定した。 (#49)
911

1012
v0.27.4
1113
-------

dialect/main.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func ParseAnyDateTime(s string) (time.Time, error) {
9999
fmt.Sprintf("%s %s%02s:%02s", m[1], m[2], m[3], m[4]))
100100
}
101101
if m := rxDateTime.FindStringSubmatch(s); m != nil {
102-
return time.Parse(DateTimeLayout, m[1])
102+
return time.ParseInLocation(DateTimeLayout, m[1], time.Local)
103103
}
104104
if m := rxDateOnly.FindStringSubmatch(s); m != nil {
105105
return time.Parse(DateOnlyLayout, m[1])
@@ -108,7 +108,7 @@ func ParseAnyDateTime(s string) (time.Time, error) {
108108
return time.Parse(TimeTzLayout, m[1])
109109
}
110110
if m := rxTimeOnly.FindStringSubmatch(s); m != nil {
111-
return time.Parse(TimeOnlyLayout, m[1])
111+
return time.ParseInLocation(TimeOnlyLayout, m[1], time.Local)
112112
}
113113
if m := rxRawLayout.FindStringSubmatch(s); m != nil {
114114
return time.Parse(RawTimeLayout, m[1])
@@ -202,7 +202,7 @@ type PlaceHolderName struct {
202202
}
203203

204204
func (ph *PlaceHolderName) Make(v any) string {
205-
ph.values = append(ph.values, v)
205+
ph.values = append(ph.values, repair(v))
206206
return fmt.Sprintf("%s%s%d", ph.Prefix, ph.Format, len(ph.values))
207207
}
208208

@@ -213,3 +213,20 @@ func (ph *PlaceHolderName) Values() (result []any) {
213213
ph.values = ph.values[:0]
214214
return
215215
}
216+
217+
func repair(v any) any {
218+
if t, ok := v.(time.Time); ok {
219+
if loc := t.Location(); loc != nil && loc.String() == "" {
220+
return time.Date(
221+
t.Year(),
222+
t.Month(),
223+
t.Day(),
224+
t.Hour(),
225+
t.Minute(),
226+
t.Second(),
227+
t.Nanosecond(),
228+
time.Local)
229+
}
230+
}
231+
return v
232+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/nyaosorg/go-box/v3 v3.1.1
1717
github.com/nyaosorg/go-readline-ny v1.15.1
1818
github.com/nyaosorg/go-ttyadapter v0.7.0
19-
github.com/sijms/go-ora/v2 v2.9.0
19+
github.com/sijms/go-ora/v2 v2.8.22
2020
)
2121

2222
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmd
6464
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6565
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
6666
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
67-
github.com/sijms/go-ora/v2 v2.9.0 h1:+iQbUeTeCOFMb5BsOMgUhV8KWyrv9yjKpcK4x7+MFrg=
68-
github.com/sijms/go-ora/v2 v2.9.0/go.mod h1:QgFInVi3ZWyqAiJwzBQA+nbKYKH77tdp1PYoCqhR2dU=
67+
github.com/sijms/go-ora/v2 v2.8.22 h1:3ABgRzVKxS439cEgSLjFKutIwOyhnyi4oOSBywEdOlU=
68+
github.com/sijms/go-ora/v2 v2.8.22/go.mod h1:QgFInVi3ZWyqAiJwzBQA+nbKYKH77tdp1PYoCqhR2dU=
6969
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
7070
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
7171
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=

test/test-oracle.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $script = `
1919
" TO_TIMESTAMP('2024-07-08 17:18:19.8787','YYYY-MM-DD HH24:MI:SS.FF')) ||" +
2020
"COMMIT||" +
2121
"EDIT TESTTBL||" +
22-
"/10|lr2015-06-07 20:21:22|lr2024-08-09 10:11:12.7878 +09:00|cyy" +
22+
"/10|lr2015-06-07 20:21:22|lr2024-08-09 10:11:12.7878 +09:00|qyy" +
2323
"SPOOL $testLst||" +
2424
"SELECT * FROM TESTTBL||" +
2525
"SPOOL OFF ||" +

0 commit comments

Comments
 (0)