diff --git a/src/parser/grammar.ne b/src/parser/grammar.ne index ca7061fb3d..a13a97772d 100644 --- a/src/parser/grammar.ne +++ b/src/parser/grammar.ne @@ -249,7 +249,7 @@ square_brackets -> "[" free_form_sql:* "]" {% }) %} -property_access -> atomic_expression _ %DOT _ (identifier | array_subscript | all_columns_asterisk) {% +property_access -> atomic_expression _ %DOT _ (identifier | array_subscript | all_columns_asterisk | parameter) {% // Allowing property to be is currently a hack. // A better way would be to allow on the left side of array_subscript, // but we currently can't do that because of another hack that requires diff --git a/test/options/paramTypes.ts b/test/options/paramTypes.ts index 3b1d466d77..dd1fde49b9 100644 --- a/test/options/paramTypes.ts +++ b/test/options/paramTypes.ts @@ -95,5 +95,20 @@ export default function supportsParamTypes(format: FormatFn) { second; `); }); + + // Normal SQL prepared statement parameters cannot really occur like this, + // but we support this to facilitate using the paramTypes config for + // working around SQL templating. + it('supports parameterizing schema.table.column syntax', () => { + const result = format('SELECT {schema}.{table}.{column} FROM {schema}.{table}', { + paramTypes: { custom: [{ regex: String.raw`\{\w+\}` }] }, + }); + expect(result).toBe(dedent` + SELECT + {schema}.{table}.{column} + FROM + {schema}.{table} + `); + }); }); }