From 653cfc81e64930b26c591c17364fbfb73bcee74b Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Mon, 13 Nov 2023 17:52:42 +0200 Subject: [PATCH] Support LIMIT clause in DB2 and DB2i Turns out that DB2 documentation does mention the LIMIT clause, but it's sneakily hidden at the bottom of the documentation page and not included to the syntax diagram at the top. --- src/languages/db2/db2.formatter.ts | 1 + src/languages/db2i/db2i.formatter.ts | 1 + test/db2.test.ts | 2 +- test/db2i.test.ts | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/languages/db2/db2.formatter.ts b/src/languages/db2/db2.formatter.ts index 1941baa0e1..afd7e66d0d 100644 --- a/src/languages/db2/db2.formatter.ts +++ b/src/languages/db2/db2.formatter.ts @@ -14,6 +14,7 @@ const reservedClauses = expandPhrases([ 'HAVING', 'PARTITION BY', 'ORDER BY [INPUT SEQUENCE]', + 'LIMIT', 'OFFSET', 'FETCH NEXT', 'FOR UPDATE [OF]', diff --git a/src/languages/db2i/db2i.formatter.ts b/src/languages/db2i/db2i.formatter.ts index 62bbf16fe7..f4da84f93c 100644 --- a/src/languages/db2i/db2i.formatter.ts +++ b/src/languages/db2i/db2i.formatter.ts @@ -15,6 +15,7 @@ const reservedClauses = expandPhrases([ 'HAVING', 'PARTITION BY', 'ORDER [SIBLINGS] BY [INPUT SEQUENCE]', + 'LIMIT', 'OFFSET', 'FETCH {FIRST | NEXT}', 'FOR UPDATE [OF]', diff --git a/test/db2.test.ts b/test/db2.test.ts index 7e106cfe47..8dc642a3fc 100644 --- a/test/db2.test.ts +++ b/test/db2.test.ts @@ -19,7 +19,7 @@ describe('Db2Formatter', () => { behavesLikeDb2Formatter(format); supportsComments(format); - supportsLimiting(format, { fetchNext: true, offset: true }); + supportsLimiting(format, { limit: true, fetchNext: true, offset: true }); supportsCreateTable(format); supportsAlterTable(format, { addColumn: true, diff --git a/test/db2i.test.ts b/test/db2i.test.ts index 19b6532206..d59d608a77 100644 --- a/test/db2i.test.ts +++ b/test/db2i.test.ts @@ -16,7 +16,7 @@ describe('Db2iFormatter', () => { behavesLikeDb2Formatter(format); supportsComments(format, { nestedBlockComments: true }); - supportsLimiting(format, { fetchNext: true, fetchFirst: true, offset: true }); + supportsLimiting(format, { limit: true, fetchNext: true, fetchFirst: true, offset: true }); supportsCreateTable(format, { orReplace: true }); supportsAlterTable(format, { addColumn: true,