Skip to content

Commit 693964d

Browse files
authored
Support array slice operator in Postgres (#652)
2 parents e117497 + c3c76b6 commit 693964d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/languages/postgresql/postgresql.formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,11 @@ export const postgresql: DialectOptions = {
357357
'<->>>',
358358
// Type cast
359359
'::',
360+
':',
360361
],
361362
},
362363
formatOptions: {
363-
alwaysDenseOperators: ['::'],
364+
alwaysDenseOperators: ['::', ':'],
364365
onelineClauses,
365366
},
366367
};

test/postgresql.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ describe('PostgreSqlFormatter', () => {
233233
`);
234234
});
235235

236+
// Regression test for issue #624
237+
it('supports array slice operator', () => {
238+
expect(format('SELECT foo[:5], bar[1:], baz[1:5], zap[:];')).toBe(dedent`
239+
SELECT
240+
foo[:5],
241+
bar[1:],
242+
baz[1:5],
243+
zap[:];
244+
`);
245+
});
246+
236247
it('formats ALTER TABLE ... ALTER COLUMN', () => {
237248
expect(
238249
format(

0 commit comments

Comments
 (0)