Skip to content

fix: [#699] database timezone#1061

Merged
hwbrzzl merged 1 commit intomasterfrom
bowen/#699-1
Jun 5, 2025
Merged

fix: [#699] database timezone#1061
hwbrzzl merged 1 commit intomasterfrom
bowen/#699-1

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Jun 5, 2025

📑 Description

Closes goravel/goravel#699

Currently, for Timestamps column of Postgres and Sqlserver, 2025-06-05 14:46:29 +08:00 will be saved with 2025-06-05 14:46:29, but when reading, ORM considers that the timezone is UTC, the timezone metadata is missed.

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings June 5, 2025 07:16
@hwbrzzl hwbrzzl requested a review from a team as a code owner June 5, 2025 07:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures timestamp columns preserve timezone metadata by switching from Timestamps to TimestampsTz in migrations and tests, and removes now-obsolete manual stubs.

  • Swapped table.Timestamps() calls to table.TimestampsTz() in the default dummy migration and creator tests
  • Deleted dialect-specific stub implementations from stubs.go, consolidating stub logic

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
database/migration/stubs.go Updated default dummy migration to use TimestampsTz and removed manual stubs for drivers
database/migration/creator_test.go Updated test to expect TimestampsTz instead of Timestamps
Comments suppressed due to low confidence (2)

database/migration/stubs.go:89

  • There are no tests covering the timezone-aware output for dialect-specific migration stubs. Consider adding tests to validate that stub generation for each driver includes timezone-aware timestamp definitions.
}

database/migration/stubs.go:48

  • Removing the dialect-specific stub implementations will break migration generation for MySQL, Postgres, SQLite, and SQLServer. Please reinstate or regenerate these stubs with timezone-aware timestamp columns rather than deleting them entirely.
table.TimestampsTz()

@codecov
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.31%. Comparing base (6b6b6a8) to head (52510f6).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1061   +/-   ##
=======================================
  Coverage   71.31%   71.31%           
=======================================
  Files         181      181           
  Lines       12732    12732           
=======================================
  Hits         9080     9080           
  Misses       3263     3263           
  Partials      389      389           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

func (receiver PostgresStubs) CreateUp() string {
return `CREATE TABLE DummyTable (
id SERIAL PRIMARY KEY NOT NULL,
created_at timestamp NOT NULL,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's removed here.

@hwbrzzl hwbrzzl merged commit 6940493 into master Jun 5, 2025
16 of 18 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#699-1 branch June 5, 2025 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Timestamps columns of Postgres and Sqlserver will lose the timezone metadata when reading

2 participants