Skip to content

Support UNION clause #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
albin3 opened this issue Oct 9, 2017 · 8 comments
Closed

Support UNION clause #2

albin3 opened this issue Oct 9, 2017 · 8 comments

Comments

@albin3
Copy link
Member

albin3 commented Oct 9, 2017

https://dev.mysql.com/doc/refman/8.0/en/union.html

@shtse8
Copy link

shtse8 commented Nov 20, 2017

Can it support dash quote? like

SELECT `attribute` FROM `table`

@albin3
Copy link
Member Author

albin3 commented Nov 23, 2017

@shtse8 supported at js-sql-parser@1.0.2

@morenoh149
Copy link

which commit added this functionality? 6d526bd ?

@albin3
Copy link
Member Author

albin3 commented Nov 26, 2017

@morenoh149 UNION feature not supported yet.

@yuemingl
Copy link

yuemingl commented Jul 8, 2019

Any update for union? I think it is important for data set generation from mixed sources in some applications.

@yuemingl
Copy link

yuemingl commented 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

@albin3
Copy link
Member Author

albin3 commented Jul 22, 2019

supported since js-sql-parser@1.0.8

@albin3 albin3 closed this as completed Jul 22, 2019
@albin3
Copy link
Member Author

albin3 commented Jul 22, 2019

@morenoh149 @yuemingl Union feature has supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants