diff --git a/src/languages/postgresql/postgresql.formatter.ts b/src/languages/postgresql/postgresql.formatter.ts index 768e32e16e..4ea02dc43a 100644 --- a/src/languages/postgresql/postgresql.formatter.ts +++ b/src/languages/postgresql/postgresql.formatter.ts @@ -357,10 +357,11 @@ export const postgresql: DialectOptions = { '<->>>', // Type cast '::', + ':', ], }, formatOptions: { - alwaysDenseOperators: ['::'], + alwaysDenseOperators: ['::', ':'], onelineClauses, }, }; diff --git a/test/postgresql.test.ts b/test/postgresql.test.ts index f875bb1a24..b3dc4adaad 100644 --- a/test/postgresql.test.ts +++ b/test/postgresql.test.ts @@ -233,6 +233,17 @@ describe('PostgreSqlFormatter', () => { `); }); + // Regression test for issue #624 + it('supports array slice operator', () => { + expect(format('SELECT foo[:5], bar[1:], baz[1:5], zap[:];')).toBe(dedent` + SELECT + foo[:5], + bar[1:], + baz[1:5], + zap[:]; + `); + }); + it('formats ALTER TABLE ... ALTER COLUMN', () => { expect( format(