Repository navigation
Support UNION clause #2
Description
Activity
Can it support dash quote? like
SELECT `attribute` FROM `table`
@shtse8 supported at js-sql-parser@1.0.2
Reacted by Kyle Tsewhich commit added this functionality? 6d526bd ?
@morenoh149 UNION feature not supported yet.
Any update for union? I think it is important for data set generation from mixed sources in some applications.
This is a working change:
sqlParser.jison
UNION return 'UNION'
selectClause
: SELECT
distinctOpt
highPriorityOpt
maxStateMentTimeOpt
straightJoinOpt
sqlSmallResultOpt
sqlBigResultOpt
sqlBufferResultOpt
sqlCacheOpt
sqlCalcFoundRowsOpt
selectExprList
selectDataSetOpt
unionStatementsOpt
{
$$ = {
type: 'Select',
distinctOpt: $2,
highPriorityOpt: $3,
maxStateMentTimeOpt: $4,
straightJoinOpt: $5,
sqlSmallResultOpt: $6,
sqlBigResultOpt: $7,
sqlBufferResultOpt: $8,
sqlCacheOpt: $9,
sqlCalcFoundRowsOpt: $10,
selectItems: $11,
from: $12.from,
partition: $12.partition,
where: $12.where,
groupBy: $12.groupBy,
having: $12.having,
orderBy: $12.orderBy,
limit: $12.limit,
procedure: $12.procedure,
updateLockMode: $12.updateLockMode,
union: $13
}
}
;
unionStatementsOpt
: unionStatementsOpt unionStatement { $$ = $2 }
| { $$ = null }
;
unionStatement
: UNION selectClause { $$ = {select: $2} }
;main.test.js
it ('test15', function () {
testParser(SELECT * from A UNION SELECT * from B UNION SELECT * from C);
});For the test above, the ast looks like:
nodeType: "Main"
value:
-type: "Select"
-union:
--select:
---type: "Select"
---union:
----select:
----type: "Select"
-----union: null- added a commit that references this issue
on Jul 9, 2019 supported since
js-sql-parser@1.0.8@morenoh149 @yuemingl Union feature has supported.
https://dev.mysql.com/doc/refman/8.0/en/union.html