Skip to content

Commit 3e584b0

Browse files
committed
Reduce the number of WITH TIMEZONE tests
1 parent 35db491 commit 3e584b0

File tree

3 files changed

+22
-56
lines changed

3 files changed

+22
-56
lines changed

test/behavesLikePostgresqlFormatter.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,17 @@ export default function behavesLikePostgresqlFormatter(format: FormatFn) {
160160
CREATE TABLE foo (text VARCHAR(100));
161161
`);
162162
});
163+
164+
it('formats TIMESTAMP WITH TIMEZONE as data type', () => {
165+
expect(
166+
format(`create table time_table (id int primary key, created_at timestamp with time zone);`, {
167+
dataTypeCase: 'upper',
168+
})
169+
).toBe(dedent`
170+
create table time_table (
171+
id INT primary key,
172+
created_at TIMESTAMP WITH TIME ZONE
173+
);
174+
`);
175+
});
163176
}

test/duckdb.test.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -182,35 +182,6 @@ describe('DuckDBFormatter', () => {
182182
`);
183183
});
184184

185-
it('formats TIMESTAMP WITH TIME ZONE syntax', () => {
186-
expect(
187-
format(`
188-
CREATE TABLE time_table (id INT PRIMARY KEY NOT NULL,
189-
created_at TIMESTAMP WITH TIME ZONE);`)
190-
).toBe(dedent`
191-
CREATE TABLE time_table (
192-
id INT PRIMARY KEY NOT NULL,
193-
created_at TIMESTAMP WITH TIME ZONE
194-
);
195-
`);
196-
});
197-
198-
it('formats TIMESTAMP WITH TIME ZONE syntax lowercase', () => {
199-
expect(
200-
format(
201-
`
202-
CREATE TABLE time_table (id INT PRIMARY KEY NOT NULL,
203-
created_at TIMESTAMP WITH TIME ZONE);`,
204-
{ dataTypeCase: 'lower' }
205-
)
206-
).toBe(dedent`
207-
CREATE TABLE time_table (
208-
id int PRIMARY KEY NOT NULL,
209-
created_at timestamp with time zone
210-
);
211-
`);
212-
});
213-
214185
it('formats JSON data type', () => {
215186
expect(
216187
format(`CREATE TABLE foo (bar json, baz json);`, {

test/postgresql.test.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -157,39 +157,21 @@ describe('PostgreSqlFormatter', () => {
157157
`);
158158
});
159159

160-
// Format timestamp as datatype
160+
// Regression test for issues #391 and #618
161+
// PostgreSQL-specific variations of WITH TIME ZONE syntax
161162
it('formats TIMESTAMP WITH TIME ZONE syntax', () => {
162163
expect(
163164
format(
164-
`
165-
CREATE TABLE time_table (id INT,
166-
created_at TIMESTAMP WITH TIME ZONE,
167-
deleted_at TIME WITH TIME ZONE,
168-
modified_at TIMESTAMP(0) WITH TIME ZONE);`,
169-
{ dataTypeCase: 'lower' }
165+
`create table time_table (id int,
166+
created_at timestamp without time zone,
167+
deleted_at time with time zone,
168+
modified_at timestamp(0) with time zone);`,
169+
{ dataTypeCase: 'upper' }
170170
)
171171
).toBe(dedent`
172-
CREATE TABLE time_table (
173-
id int,
174-
created_at timestamp with time zone,
175-
deleted_at time with time zone,
176-
modified_at timestamp(0) with time zone
177-
);
178-
`);
179-
});
180-
181-
// Regression test for issues #391 and #618
182-
it('formats TIMESTAMP WITH TIME ZONE syntax', () => {
183-
expect(
184-
format(`
185-
CREATE TABLE time_table (id INT,
186-
created_at TIMESTAMP WITH TIME ZONE,
187-
deleted_at TIME WITH TIME ZONE,
188-
modified_at TIMESTAMP(0) WITH TIME ZONE);`)
189-
).toBe(dedent`
190-
CREATE TABLE time_table (
172+
create table time_table (
191173
id INT,
192-
created_at TIMESTAMP WITH TIME ZONE,
174+
created_at TIMESTAMP WITHOUT TIME ZONE,
193175
deleted_at TIME WITH TIME ZONE,
194176
modified_at TIMESTAMP(0) WITH TIME ZONE
195177
);

0 commit comments

Comments
 (0)