Improve Oracle DATE/TIMESTAMP handling#57
Merged
Merged
Conversation
…cific value formatting
hymkor
added a commit
that referenced
this pull request
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves Oracle DATE/TIMESTAMP handling and avoids timezone-dependent behavior caused by differences in Oracle driver implementations.
Instead of relying on Go
time.Timetimezone handling, Oracle datetime values are now converted through database-specific string formatting and SQL-sideTO_DATE/TO_TIMESTAMPconversion.Changes
FormatValuehook todialect.Entryrowstocsvspreadselectandeditnow use database-specific cell formattingDATEvalues are formatted as:2006-01-02 15:04:05TIMESTAMPvalues are formatted as:2006-01-02 15:04:05.999999999TO_DATE/TO_TIMESTAMPfor Oracle datetime comparisons and updatesNotes
Oracle
DATEandTIMESTAMPcolumns do not contain timezone information, but different versions ofgo-oraattach different timezone metadata to Gotime.Timevalues.This PR avoids relying on timezone behavior and instead uses timezone-independent string representations for Oracle datetime handling.
Unlike [#49](#49), this approach should theoretically work with both
go-orav2.8.x and v2.9.x.go-ora ドライバーって、2.8 だと time.Time に入ってくるタイムゾーンが time.Local になるのに、2.9 だと UTC になってしまいます。で、それだとレコードの照合がうまくいかなくなるのが困るので、#55 では、日時の照合と日時の名前の値ではなく、TO_DATE , TO_TIMESTAMP を経由使って行うようにしました。
その結果として、edit コマンドや select コマンドで出てくるタイムゾーン情報(例:+09:00)は無意味になってしまいました(ユーザが編集しても使わない)。ならばそもそも表示しないようにしようというのが本修正です。
ただし、Oracle 向けの特別扱いはよくないため、本修正では、各DBごとに SELECT/EDIT 文で出す表現情報をカスタマイズできるような仕組みを作ってから、それを使いました。今後、他の DB 向けにもこの仕組みを使うと思います。
(dialent サブパッケージの Entry 構造体の FormatValue フィールドに格納されている関数に型名と値を渡せば、その DB 固有の表現が得られるという仕組み。ただし、フィールドが空の場合や、第二戻り値が false の場合は固有のカスタマイズはないと解釈しなければいけない)