https://dev.mysql.com/doc/refman/8.0/en/union.html
Activity
shtse8 commentedon Nov 20, 2017
Can it support dash quote? like
albin3 commentedon Nov 23, 2017
@shtse8 supported at js-sql-parser@1.0.2
morenoh149 commentedon Nov 24, 2017
which commit added this functionality? 6d526bd ?
albin3 commentedon Nov 26, 2017
@morenoh149 UNION feature not supported yet.
yuemingl commentedon Jul 8, 2019
Any update for union? I think it is important for data set generation from mixed sources in some applications.
yuemingl commentedon Jul 8, 2019
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
feat: union grammar, to resolve grammar conflicts. #2
albin3 commentedon Jul 22, 2019
supported since
js-sql-parser@1.0.8albin3 commentedon Jul 22, 2019
@morenoh149 @yuemingl Union feature has supported.