You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I won't handle tests this time since there is a lot of confusion around them about this subject. I'll let maintainers merge this as-is or update the relevant tests
This fixes getting Date objects from cached entities instead of strings for columns marked as timestamptz (like it was the case for timestamp with time zone).
The PR adds timestamptz handling in two locations but may be missing other places where timestamp types are checked. Search the codebase for other conditional checks involving timestamp with time zone or timestamp without time zone to ensure timestamptz is handled consistently throughout the driver.
columnMetadata.type==="timestamptz"||columnMetadata.type==="timestamp with time zone"||
Minishlink
changed the title
fix/timestamptz parsing
fix(postgres): treat 'timestamptz' same as 'timestamp with time zone'
Jan 12, 2026
To prevent potential data loss, handle timestamptz and timestamp with time zone types separately to ensure timezone information is preserved when persisting values.
if (
columnMetadata.type === "datetime" ||
columnMetadata.type === Date ||
columnMetadata.type === "timestamp" ||
- columnMetadata.type === "timestamptz" ||- columnMetadata.type === "timestamp with time zone" ||
columnMetadata.type === "timestamp without time zone"
) {
return DateUtils.mixedDateToDate(value)
+} else if (+ columnMetadata.type === "timestamptz" ||+ columnMetadata.type === "timestamp with time zone"+) {+ return DateUtils.mixedDateToDate(value, { keepTimezone: true })
[To ensure code accuracy, apply this suggestion manually]
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential data integrity issue where timezone information for timestamptz columns might be lost, as the PR treats timezone-aware and timezone-unaware types identically.
For timestamptz and timestamp with time zone types, modify the DateUtils.mixedDateToDate call to include an option that preserves timezone information, ensuring correct data persistence.
} else if (
columnMetadata.type === "datetime" ||
columnMetadata.type === Date ||
columnMetadata.type === "timestamp" ||
columnMetadata.type === "timestamptz" ||
columnMetadata.type === "timestamp with time zone" ||
columnMetadata.type === "timestamp without time zone"
) {
- return DateUtils.mixedDateToDate(value)+ return DateUtils.mixedDateToDate(value, {+ utc: columnMetadata.type === "timestamptz" || columnMetadata.type === "timestamp with time zone"+ })
Suggestion importance[1-10]: 8
__
Why: The suggestion correctly identifies a potential data handling bug where treating the timezone-aware timestamptz type identically to non-timezone-aware types could lead to loss of timezone information.
Centralize the handling of the timestamptz type alias by normalizing it to timestamp with time zone in a single normalizeType method, rather than adding redundant checks in multiple places.
columnMetadata.type === "datetime" ||
columnMetadata.type === Date ||
columnMetadata.type === "timestamp" ||
-columnMetadata.type === "timestamptz" ||
columnMetadata.type === "timestamp with time zone" ||
columnMetadata.type === "timestamp without time zone"
Suggestion importance[1-10]: 7
__
Why: The suggestion provides a good refactoring opportunity by proposing to centralize type alias handling, which would reduce code duplication and improve maintainability, instead of adding the same check in multiple methods.
• The PR adds timestamptz checks to handle the PostgreSQL alias for 'timestamp with time zone',
but fails to add the parallel timetz checks for 'time with time zone'
• Both timestamptz and timetz are valid PostgreSQL type aliases that users can specify in column
definitions (e.g., @Column({ type: 'timetz' }))
• When a column is defined with type: 'timetz', the preparePersistentValue and
prepareHydratedValue methods will not properly convert time values, causing incorrect data
persistence and retrieval
• This creates an inconsistency where timestamptz is now fully supported but timetz remains
partially supported (works in schema but not in data conversion)
The evidence demonstrates that: (1) timetz is a valid, supported PostgreSQL type alias listed in
supportedDataTypes and handled by normalizeType, (2) the preparePersistentValue method only checks
for 'time' without checking for 'timetz' or 'time with time zone', (3) the prepareHydratedValue
method has the same gap, (4) columnMetadata.type contains the original type string as specified by
the user, not the normalized form, (5) test files show real-world usage of timestamptz, confirming
users do use these aliases, (6) the PR adds timestamptz but not timetz, creating an inconsistency.
## Issue Description
The PR adds support for the `timestamptz` PostgreSQL type alias but fails to add the parallel support for `timetz` (time with time zone alias). Both aliases should be handled consistently in the type conversion methods.
## Issue Context
- PostgreSQL supports type aliases: `timestamptz` for 'timestamp with time zone' and `timetz` for 'time with time zone'
- The driver already recognizes `timetz` in supportedDataTypes and normalizeType method
- Users can define columns with `@Column({ type: 'timetz' })` but these columns won't be properly converted during persistence/hydration
- The PR correctly adds `timestamptz` checks but misses the parallel `timetz` checks
## Fix Focus Areas
### 1. preparePersistentValue method - Add timetz handling
- src/driver/postgres/PostgresDriver.ts[741-751]
Modify the time type check to include 'timetz' and 'time with time zone':
```typescript
} else if (
columnMetadata.type === "time" ||
columnMetadata.type === "timetz" ||
columnMetadata.type === "time with time zone" ||
columnMetadata.type === "time without time zone"
) {
return DateUtils.mixedDateToTimeString(value)
}
```
### 2. prepareHydratedValue method - Add timetz handling
- src/driver/postgres/PostgresDriver.ts[844-845]
Modify the time type check to include 'timetz' and 'time with time zone':
```typescript
} else if (
columnMetadata.type === "time" ||
columnMetadata.type === "timetz" ||
columnMetadata.type === "time with time zone" ||
columnMetadata.type === "time without time zone"
) {
value = DateUtils.mixedTimeToString(value)
}
```
### 3. Consider fixing CockroachDB driver as well
- src/driver/cockroachdb/CockroachDriver.ts[391-392]
- src/driver/cockroachdb/CockroachDriver.ts[453-454]
The CockroachDB driver has the same issue and should be fixed consistently.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
gioboa
changed the title
fix(postgres): treat 'timestamptz' same as 'timestamp with time zone'
fix(postgres): handle timestamptz correctly
Jan 14, 2026
gioboa
changed the title
fix(postgres): handle timestamptz correctly
fix(postgres): handle timestamptz correctly
Jan 14, 2026
1. Missing tests for timestamptz fix 📘 Rule violation✓ Correctness
Description
• The PR fixes timestamptz handling for cached entities but does not add or update tests in
test/functional.
• The PR description explicitly states 'I won't handle tests this time' which violates the
compliance requirement.
• Existing tests in test/functional/database-schema/column-types/postgres already test timestamptz
but don't cover the caching scenario that this fix addresses.
The compliance checklist requires that issue fixes add or update tests in test/functional with an
issue reference. The PR description explicitly states the author won't handle tests, and no test
files are included in the diff. The code changes in preparePersistentValue and prepareHydratedValue
functions add timestamptz handling, but there are no corresponding test updates to verify this fix
works correctly, especially for the cached entity scenario mentioned in the PR description.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The PR adds `timestamptz` handling to preparePersistentValue and prepareHydratedValue functions but lacks tests to verify the fix works correctly, especially for cached entities.
## Issue Context
The PR description mentions this fixes getting Date objects from cached entities instead of strings for columns marked as `timestamptz`. The compliance checklist requires functional tests for issue fixes.
## Fix Focus Areas
- test/functional/database-schema/column-types/postgres/column-types-postgres.test.ts[1-400]
- test/functional/query-builder/cache/query-builder-cache.test.ts[1-100]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
ⓘ The new review experience is currently in Beta. Learn more
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
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.
Follow-up of this PR #11774
I won't handle tests this time since there is a lot of confusion around them about this subject. I'll let maintainers merge this as-is or update the relevant tests
This fixes getting Date objects from cached entities instead of strings for columns marked as
timestamptz(like it was the case fortimestamp with time zone).