Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into fix-unit-of-time
  • Loading branch information
sockstack authored Jul 30, 2021
commit 6dd164a3f5b46ba1543f5c27115b7c0e18fe3843
18 changes: 18 additions & 0 deletions src/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,26 @@ Sql.prototype.travelSelectParenthesized = function(ast) {
this.travel(ast.value);
this.appendKeyword(')');
};

Sql.prototype.travelIntervalExpression = function (ast) {
this.appendKeyword('interval');
this.travel(ast.value);
this.appendKeyword(ast.unit);
};
Sql.prototype.travelPlaceHolder = function (ast) {
if (ast.left) {
this.travel(ast.left);
}

if (ast.operator) {
this.append(ast.operator);
}

if (ast.right) {
this.append(ast.right);
}

if (ast.value) {
this.travel(ast.value);
}
};
27 changes: 27 additions & 0 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,31 @@ describe('select grammar support', function () {
SELECT a, b from t1 where created_at >= DATE_SUB(NOW(),INTERVAL 1 MONTH)
`)
})

});
it('place holder support', function() {
testParser(
"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})"
)
});

it('support quoted alias: multiple alias and orderby support', function () {
testParser('select a as `A A`, b as `B B` from z');
testParser('select a as `A A` from z order by `A A` desc');
testParser('select a as `A A`, b as `B B` from z group by `A A`, `B B` order by `A A` desc');
});

it('support double quoted alias', function () {
testParser('select a as "A A" from z');
testParser('select a as "A A" from z order by "A A" desc');
});

it('support quoted alias', function () {
testParser('select a as \'A A\' from z');
testParser('select a as \'"A#A\' from z order by \'"A#A\' desc');
});

it('test IDENTIFIER', function () {
testParser('select `aa#sfs`(a) as \'A A\' from z');
});
});
You are viewing a condensed version of this merge commit. You can view the full changes here.