Skip to content

Commit

Permalink
Support @, $, # anywhere inside DB2 & DB2i identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
nene committed Nov 10, 2023
1 parent 4b2bc98 commit 8f5eb36
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/languages/db2/db2.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const db2: DialectOptions = {
{ quote: "''-raw", prefixes: ['X', 'BX', 'GX', 'UX'], requirePrefix: true },
],
identTypes: [`""-qq`],
identChars: { first: '@#$' },
identChars: { first: '@#$', rest: '@#$' },
paramTypes: { positional: true, named: [':'] },
paramChars: { first: '@#$', rest: '@#$' },
operators: ['**', '¬=', '¬>', '¬<', '!>', '!<', '||'],
Expand Down
2 changes: 1 addition & 1 deletion src/languages/db2i/db2i.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const db2i: DialectOptions = {
{ quote: "''-raw", prefixes: ['X', 'BX', 'GX', 'UX'], requirePrefix: true },
],
identTypes: [`""-qq`],
identChars: { first: '@#$' },
identChars: { first: '@#$', rest: '@#$' },
paramTypes: { positional: true },
operators: ['**', '¬=', '¬>', '¬<', '!>', '!<', '||'],
},
Expand Down
9 changes: 6 additions & 3 deletions test/behavesLikeDb2Formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,15 @@ export default function behavesLikeDb2Formatter(format: FormatFn) {
`);
});

it('supports @, #, $ characters at the start of identifiers', () => {
expect(format(`SELECT @foo, #bar, $zap`)).toBe(dedent`
it('supports @, #, $ characters anywhere inside identifiers', () => {
expect(format(`SELECT @foo, #bar, $zap, fo@o, ba#2, za$3`)).toBe(dedent`
SELECT
@foo,
#bar,
$zap
$zap,
fo@o,
ba#2,
za$3
`);
});

Expand Down

0 comments on commit 8f5eb36

Please sign in to comment.