Skip to content

Commit

Permalink
Support array slice operator in Postgres (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
nene authored Oct 23, 2023
2 parents e117497 + c3c76b6 commit 693964d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/languages/postgresql/postgresql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,11 @@ export const postgresql: DialectOptions = {
'<->>>',
// Type cast
'::',
':',
],
},
formatOptions: {
alwaysDenseOperators: ['::'],
alwaysDenseOperators: ['::', ':'],
onelineClauses,
},
};
11 changes: 11 additions & 0 deletions test/postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 693964d

Please sign in to comment.