Skip to content

Commit

Permalink
Support # and $ in PL/SQL named parameters
Browse files Browse the repository at this point in the history
Fixes #822
  • Loading branch information
nene committed Jan 25, 2025
1 parent ac92853 commit 4eb0193
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/languages/plsql/plsql.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const plsql: DialectOptions = {
identChars: { rest: '$#' },
variableTypes: [{ regex: '&{1,2}[A-Za-z][A-Za-z0-9_$#]*' }],
paramTypes: { numbered: [':'], named: [':'] },
paramChars: {}, // Empty object used on purpose to not allow $ and # chars as specified in identChars
operators: [
'**',
':=',
Expand Down
12 changes: 7 additions & 5 deletions test/plsql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ describe('PlSqlFormatter', () => {
`);
});

// Parameters don't allow the same characters as identifiers
it('does not support #, $ in named parameters', () => {
expect(() => format('SELECT :col$foo')).toThrowError(`Parse error: Unexpected "$foo"`);

expect(() => format('SELECT :col#foo')).toThrowError(`Parse error: Unexpected "#foo"`);
// Issue #822
it('supports #, $ in named parameters', () => {
expect(format('SELECT :col$foo, :col#foo')).toBe(dedent`
SELECT
:col$foo,
:col#foo
`);
});

it('supports &name substitution variables', () => {
Expand Down

0 comments on commit 4eb0193

Please sign in to comment.