|
2 | 2 |
|
3 | 3 | const debug = require('debug')('js-sql-parser');
|
4 | 4 | const parser = require('../');
|
| 5 | +const assert = require('assert'); |
5 | 6 |
|
6 | 7 | const testParser = function (sql) {
|
7 | 8 | let firstAst = parser.parse(sql);
|
@@ -416,6 +417,19 @@ describe('select grammar support', function () {
|
416 | 417 | "select sum(quota_value) value, busi_col2 as sh, ${a} as a, YEAR(now()) from der_quota_summary where table_ename = 'gshmyyszje_derivedidx' and cd = (select id from t1 where a = ${t1})"
|
417 | 418 | )
|
418 | 419 | });
|
| 420 | + it('place holder support2', function() { |
| 421 | + testParser( |
| 422 | + "select sum(quota_value) b, busi_col2 as sh, '${a}' as a, YEAR(now()) from der_quota_summary where table_ename = 'gshmyyszje_derivedidx' and cd = (select id from t1 where a = '${t1}')" |
| 423 | + ) |
| 424 | + }); |
| 425 | + it('place holder support3', function() { |
| 426 | + let firstAst = parser.parse('select ${a} as a'); |
| 427 | + firstAst['value']['selectItems']['value'][0]['value'] = "'value'"; |
| 428 | + let firstSql = parser.stringify(firstAst); |
| 429 | + debug(JSON.stringify(firstAst, null, 2)); |
| 430 | + assert.equal(firstSql.trim().toUpperCase(), "select 'value' as a".toUpperCase()); |
| 431 | + testParser(firstSql); |
| 432 | + }); |
419 | 433 |
|
420 | 434 | it('support quoted alias: multiple alias and orderby support', function () {
|
421 | 435 | testParser('select a as `A A`, b as `B B` from z');
|
|
0 commit comments