Skip to content

Support UNION clause #2

Description

@albin3

Activity

  1. shtse8 commented on Nov 20, 2017

    @shtse8

    Can it support dash quote? like

    SELECT `attribute` FROM `table`
  2. albin3 commented on Nov 23, 2017

    @albin3
    MemberAuthor

    @shtse8 supported at js-sql-parser@1.0.2

  3. morenoh149 commented on Nov 24, 2017

    @morenoh149

    which commit added this functionality? 6d526bd ?

  4. albin3 commented on Nov 26, 2017

    @albin3
    MemberAuthor

    @morenoh149 UNION feature not supported yet.

  5. yuemingl commented on Jul 8, 2019

    @yuemingl

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

  6. yuemingl commented on Jul 8, 2019

    @yuemingl

    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

  7. albin3 commented on Jul 22, 2019

    @albin3
    MemberAuthor

    supported since js-sql-parser@1.0.8

  8. albin3 commented on Jul 22, 2019

    @albin3
    MemberAuthor

    @morenoh149 @yuemingl Union feature has supported.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions