GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Missing space before UNION when building CREATE VIEW · Issue #655 · phpmyadmin/sql-parser

Missing space before UNION when building CREATE VIEW #655

New issue
Copy link
New issue
Copy link
Open
#657
Open
Missing space before UNION when building CREATE VIEW#655
#657
Copy link

Description

@predictor2718
predictor2718
opened on Apr 24, 2026
Issue body actions

Summary

When CreateStatement::build() reconstructs a CREATE VIEW ... AS SELECT ... UNION ...
statement, the output misses the whitespace between the built SELECT and the
trailing body tokens. Result: invalid SQL such as ... WHERE 3 = 3union all (...).

This was previously reported downstream in phpMyAdmin:

  • [Bug]: Exporting views with union does not put a space before the keyword union phpmyadmin#19692
  • View export missing when contain union statement phpmyadmin#18515 (same bug, older)

Reproduction

use PhpMyAdmin\SqlParser\Parser;

$sql = "CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER "
     . "VIEW `v1` AS select 1 AS `a` where 3 = 3 union all (select 2 AS `a`)";

echo (new Parser($sql))->statements[0]->build();

Actual output:

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`  AS SELECT 1 AS `a` WHERE 3 = 3union all (select 2 AS `a`)

(note: 3 = 3union all — no space).

Expected: a space before union all, producing valid SQL.

Environment

  • Library version: current master (head f440917e)
  • PHP: 8.4
Reacted by William Desportes

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.