Skip to content
Closed
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
6 changes: 5 additions & 1 deletion src/languages/postgresql/postgresql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ const reservedClauses = expandPhrases([
'FOR {UPDATE | NO KEY UPDATE | SHARE | KEY SHARE} [OF]',
// Data manipulation
// - insert:
'INSERT INTO',
'INSERT [INTO]',
'VALUES',
'DEFAULT VALUES',
// - update:
'SET',
// - merge:
'MERGE [INTO]',
'WHEN [NOT] MATCHED [BY SOURCE | BY TARGET] [THEN]',
'UPDATE SET',
// other
'RETURNING',
]);
Expand Down
3 changes: 3 additions & 0 deletions src/languages/postgresql/postgresql.functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export const functions: string[] = [
'UUID_EXTRACT_TIMESTAMP',
'UUID_EXTRACT_VERSION',

// https://www.postgresql.org/docs/17/functions-merge-support.html
'MERGE_ACTION',

// https://www.postgresql.org/docs/14/functions-xml.html
'CURSOR_TO_XML',
'CURSOR_TO_XMLSCHEMA',
Expand Down
2 changes: 2 additions & 0 deletions test/postgresql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import supportsCreateView from './features/createView.js';
import supportsIsDistinctFrom from './features/isDistinctFrom.js';
import supportsArrayLiterals from './features/arrayLiterals.js';
import supportsDataTypeCase from './options/dataTypeCase.js';
import supportsMergeInto from './features/mergeInto.js';
import behavesLikePostgresqlFormatter from './behavesLikePostgresqlFormatter.js';

describe('PostgreSqlFormatter', () => {
Expand Down Expand Up @@ -147,6 +148,7 @@ describe('PostgreSqlFormatter', () => {
supportsParams(format, { numbered: ['$'] });
supportsLimiting(format, { limit: true, offset: true, fetchFirst: true, fetchNext: true });
supportsDataTypeCase(format);
supportsMergeInto(format);

// Regression test for issue #935
it('preserves pg_dump restrict commands', () => {
Expand Down
Loading