Skip to content

Commit 39a9ac0

Browse files
authored
fix(schema-compiler): yml backtick escaping (#6478)
1 parent 16d0bcb commit 39a9ac0

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

packages/cubejs-schema-compiler/src/compiler/YamlCompiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ export class YamlCompiler {
143143
} else if (str[i] === '"' && peek().inStr) {
144144
result.push(str[i]);
145145
stateStack.pop();
146+
} else if (str[i] === '`' && stateStack.length === 0) {
147+
result.push('\\`');
148+
} else if (str[i] === '`' && peek().inStr) {
149+
result.push(str[i]);
150+
stateStack.pop();
146151
} else if (str[i] === '{' && str[i + 1] === '{' && peek()?.inFormattedStr) {
147152
result.push('{{');
148153
i += 1;

packages/cubejs-schema-compiler/test/unit/yaml-schema.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,23 @@ describe('Yaml Schema Testing', () => {
3838

3939
await compiler.compile();
4040
});
41+
42+
it('escapes backticks', async () => {
43+
const { compiler } = prepareYamlCompiler(
44+
`cubes:
45+
- name: Users
46+
sql: SELECT * FROM e2e.users
47+
dimensions:
48+
- name: id
49+
sql: id
50+
type: number
51+
primaryKey: true
52+
- name: c2
53+
sql: "{CUBE}.\`C2\`"
54+
type: string
55+
`
56+
);
57+
58+
await compiler.compile();
59+
});
4160
});

0 commit comments

Comments
 (0)