Skip to content

Commit

Permalink
Support array slice operator in Postgres
Browse files Browse the repository at this point in the history
Fixes #624
  • Loading branch information
nene committed Oct 23, 2023
1 parent e117497 commit c3c76b6
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 c3c76b6

Please sign in to comment.