Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format DEFAULT VALUES clause for Postgres #720

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/languages/postgresql/postgresql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const reservedClauses = expandPhrases([
// - insert:
'INSERT INTO',
'VALUES',
'DEFAULT VALUES',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure exactly which of the "clauses" arrays this belongs in, though it seems to not matter for the tests. If you'd rather this be moved to another array, please let me know.

// - update:
'SET',
// other
Expand Down
14 changes: 14 additions & 0 deletions test/postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,18 @@ describe('PostgreSqlFormatter', () => {
release;
`);
});

it('formats DEFAULT VALUES clause', () => {
expect(
format(`INSERT INTO items default values RETURNING id;`, {
keywordCase: 'upper',
})
).toBe(dedent`
INSERT INTO
items
DEFAULT VALUES
RETURNING
id;
`);
});
});