Skip to content

Bug fix: "Create Table" script generation dropped "with time zone" from TIMESTAMP/TIME column - #98

Open
nrworld wants to merge 1 commit into
squirrel-sql-client:masterfrom
nrworld:fix-create-script-bug
Open

Bug fix: "Create Table" script generation dropped "with time zone" from TIMESTAMP/TIME column#98
nrworld wants to merge 1 commit into
squirrel-sql-client:masterfrom
nrworld:fix-create-script-bug

Conversation

@nrworld

@nrworld nrworld commented Jul 28, 2026

Copy link
Copy Markdown

Problem

When generating a "Create Table" DDL script for an existing table (right-click table → Scripts → Create), SQuirreL emitted timestamp instead of timestamp with time zone for PostgreSQL
columns that actually have a timezone (timestamptz). The same applied to time/timetz.

Root cause

java.sql.Types.TIMESTAMP and Types.TIME don't distinguish the plain and "with time zone" variants. Every dialect registers a flat mapping (e.g. PostgreSQLDialectExt:
registerColumnType(Types.TIMESTAMP, "timestamp")), so the qualifier is silently dropped — even though it is present in the driver's real JDBC TYPE_NAME (e.g. Postgres reports
timestamptz/timetz).

Fix

Added one shared post-processing step in CommonHibernateDialect.getTypeName(TableColumnInfo) — the single chokepoint used by every dialect for both "Create Table" and "Alter Column Type"
DDL generation. After resolving the base type name, it checks the driver's raw TYPE_NAME for a timezone indicator (timestamptz, timetz, or a "with time zone" substring) and appends " with
time zone" if the resolved name doesn't already have it.

This is a shared fix rather than a Postgres-only patch, so it also covers other ANSI-timezone-capable dialects (H2, HSQLDB, Derby, Firebird, etc.) that inherit getTypeName(TableColumnInfo)
from CommonHibernateDialect without requiring any per-dialect changes.

File changed: sql12/core/src/net/sourceforge/squirrel_sql/fw/dialects/CommonHibernateDialect.java (+41/-1)

Testing

  • Manually verified

Note: Used Sonnet 5 for development of the fix

… TIMESTAMP/TIME columns.

java.sql.Types.TIMESTAMP/TIME don't distinguish plain and "with time zone"
variants, so every dialect's hard-coded type registry mapped both to the
same bare "timestamp"/"time" name, discarding the qualifier even though the
driver's real TYPE_NAME (e.g. PostgreSQL's timestamptz/timetz) carried it.
Fixed once in CommonHibernateDialect.getTypeName(TableColumnInfo), the
shared chokepoint used by every dialect's create-table and alter-column-type
SQL generation, so all dialects pick up the fix without per-dialect changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant