Skip to content

Commit c598126

Browse files
committed
Allow DB2 identifiers to start with $, @, # chars
Fixes #550
1 parent de64b3b commit c598126

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/languages/db2/db2.formatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export const db2: DialectOptions = {
190190
{ quote: "''-raw", prefixes: ['X', 'BX', 'GX', 'UX'], requirePrefix: true },
191191
],
192192
identTypes: [`""-qq`],
193+
identChars: { first: '@#$' },
193194
paramTypes: { positional: true, named: [':'] },
194195
paramChars: { first: '@#$', rest: '@#$' },
195196
operators: ['**', '¬=', '¬>', '¬<', '!>', '!<', '||'],

test/db2.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ describe('Db2Formatter', () => {
8989
`);
9090
});
9191

92+
it('supports @, #, $ characters at the start of identifiers', () => {
93+
expect(format(`SELECT @foo, #bar, $zap`)).toBe(dedent`
94+
SELECT
95+
@foo,
96+
#bar,
97+
$zap
98+
`);
99+
});
100+
92101
it('supports @, #, $ characters in named parameters', () => {
93102
expect(format(`SELECT :foo@bar, :foo#bar, :foo$bar, :@zip, :#zap, :$zop`)).toBe(dedent`
94103
SELECT

0 commit comments

Comments
 (0)