diff --git a/src/languages/db2/db2.formatter.ts b/src/languages/db2/db2.formatter.ts index 34c09250c7..1941baa0e1 100644 --- a/src/languages/db2/db2.formatter.ts +++ b/src/languages/db2/db2.formatter.ts @@ -16,6 +16,11 @@ const reservedClauses = expandPhrases([ 'ORDER BY [INPUT SEQUENCE]', 'OFFSET', 'FETCH NEXT', + 'FOR UPDATE [OF]', + 'FOR {READ | FETCH} ONLY', + 'FOR {RR | CS | UR | RS} [USE AND KEEP {SHARE | UPDATE | EXCLUSIVE} LOCKS]', + 'WAIT FOR OUTCOME', + 'SKIP LOCKED DATA', // Data modification // - insert: 'INSERT INTO', diff --git a/test/db2.test.ts b/test/db2.test.ts index 6d739071fc..7e106cfe47 100644 --- a/test/db2.test.ts +++ b/test/db2.test.ts @@ -1,3 +1,5 @@ +import dedent from 'dedent-js'; + import { format as originalFormat, FormatFn } from '../src/sqlFormatter.js'; import behavesLikeDb2Formatter from './behavesLikeDb2Formatter.js'; @@ -47,4 +49,17 @@ describe('Db2Formatter', () => { ]); // Additional U& string type in addition to others shared by all DB2 implementations supportsStrings(format, ["U&''"]); + + it('supports non-standard FOR clause', () => { + expect(format('SELECT * FROM tbl FOR UPDATE OF other_tbl FOR RS USE AND KEEP EXCLUSIVE LOCKS')) + .toBe(dedent` + SELECT + * + FROM + tbl + FOR UPDATE OF + other_tbl + FOR RS USE AND KEEP EXCLUSIVE LOCKS + `); + }); });