File tree Expand file tree Collapse file tree 2 files changed +63
-1
lines changed
packages/cubejs-schema-compiler Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ class ScaffoldingTemplate {
97
97
const items = descriptor . map ( desc => this . render ( desc , level + 1 ) ) . join ( ', ' ) ;
98
98
return `[${ items } ]` ;
99
99
} else if ( typeof descriptor === 'string' ) {
100
- return "`" + descriptor + "`" ;
100
+ return `\` ${ descriptor . replace ( / ` / g , '\\`' ) } \`` ;
101
101
} else if ( descriptor instanceof MemberReference ) {
102
102
return descriptor . member ;
103
103
} else if ( typeof descriptor === 'object' ) {
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ const driver = {
6
6
quoteIdentifier : ( name ) => `"${ name } "`
7
7
} ;
8
8
9
+ const mySqlDriver = {
10
+ quoteIdentifier : ( name ) => `\`${ name } \``
11
+ } ;
12
+
9
13
describe ( 'ScaffoldingSchema' , ( ) => {
10
14
it ( 'schema' , ( ) => {
11
15
const schema = new ScaffoldingSchema ( {
@@ -399,6 +403,64 @@ describe('ScaffoldingSchema', () => {
399
403
}
400
404
}
401
405
});
406
+ `
407
+ }
408
+ ] ) ;
409
+ } ) ;
410
+
411
+ it ( 'escaping back tick' , ( ) => {
412
+ const template = new ScaffoldingTemplate ( {
413
+ public : {
414
+ someOrders : [ {
415
+ "name" : "id" ,
416
+ "type" : "integer" ,
417
+ "attributes" : [ ]
418
+ } , {
419
+ "name" : "amount" ,
420
+ "type" : "integer" ,
421
+ "attributes" : [ ]
422
+ } , {
423
+ "name" : "someDimension" ,
424
+ "type" : "string" ,
425
+ "attributes" : [ ]
426
+ } ]
427
+ }
428
+ } , mySqlDriver ) ;
429
+ template . generateFilesByTableNames ( [ 'public.someOrders' ] ) . should . be . deepEqual ( [
430
+ {
431
+ fileName : 'SomeOrders.js' ,
432
+ content : `cube(\`SomeOrders\`, {
433
+ sql: \`SELECT * FROM public.\\\`someOrders\\\`\`,
434
+
435
+ joins: {
436
+
437
+ },
438
+
439
+ measures: {
440
+ count: {
441
+ type: \`count\`,
442
+ drillMembers: [id]
443
+ },
444
+
445
+ amount: {
446
+ sql: \`amount\`,
447
+ type: \`sum\`
448
+ }
449
+ },
450
+
451
+ dimensions: {
452
+ id: {
453
+ sql: \`id\`,
454
+ type: \`number\`,
455
+ primaryKey: true
456
+ },
457
+
458
+ somedimension: {
459
+ sql: \`\${CUBE}.\\\`someDimension\\\`\`,
460
+ type: \`string\`
461
+ }
462
+ }
463
+ });
402
464
`
403
465
}
404
466
] ) ;
You can’t perform that action at this time.
0 commit comments