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 — fix(builder): preserve whitespace between SELECT and UNION body in CREATE VIEW (#655) by SAY-5 · Pull Request #657 · phpmyadmin/sql-parser

Conversation

@SAY-5

@SAY-5 SAY-5 commented Apr 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

Fixes #655. CreateStatement::build() reconstructed CREATE VIEW ... AS SELECT ... UNION ... by concatenating $builtStatement = $this->select->build() directly with TokensList::buildFromArray($this->body). Neither side carried a separator, so the rebuilt SQL collided the SELECT's last token with the UNION:

... WHERE 3 = 3union all (...)

This was reported downstream in phpmyadmin/phpmyadmin#19692 (and earlier as #18515), the syntax-invalid output broke phpMyAdmin's exports.

Change

src/Statements/CreateStatement.php, insert a single space when both sides are non-empty and neither already ends/begins with a space. The existing WITH ... AS ( ... ) SELECT ... path already produces a trailing space on $builtStatement, so the conditional avoids double-spacing it.

Test plan

  • vendor/bin/phpunit tests/Builder/, 110/110 pass (including the existing testBuilderView which already exercised UNION on a different shape)
  • New testBuilderViewWithUnionPreservesWhitespace reproducing the issue's exact CREATE ALGORITHM=UNDEFINED ... AS select 1 AS \`a\` where 3 = 3 union all (...) input. Asserts:
    • rebuilt SQL does not contain 3union all (collision)
    • rebuilt SQL does contain 3 union all (case-normalised)
  • Existing WITH+UNION test (CREATE view view_name AS WITH aa(col1) AS (...) SELECT ...) unchanged, the conditional separator preserves its prior trailing-space output

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
SAY-5 added 2 commits April 30, 2026 00:38
@SAY-5
fix(builder): preserve whitespace between SELECT and UNION body in CR…
29a63b1
…EATE VIEW (phpmyadmin#655)

Signed-off-by: SAY-5 <[email protected]>
@SAY-5
chore: remove em-dashes from comments
91123d2
@SAY-5

SAY-5 commented Aug 23, 2026

Copy link
Copy Markdown
Author

Bumping this. The builder currently glues SELECT straight onto the UNION body so the rebuilt query comes back malformed, patch just keeps the space.

williamdes reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

williamdes
williamdes approved these changes Oct 13, 2026
View reviewed changes

@williamdes williamdes left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you !
And thank you for adding a test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@williamdes williamdes added this to the 5.11.3 milestone Oct 13, 2026
@williamdes williamdes self-assigned this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@williamdes williamdes williamdes approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@williamdes williamdes

Labels

None yet

Projects

None yet

Milestone

5.11.3

Development

Successfully merging this pull request may close these issues.

Missing space before UNION when building CREATE VIEW

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@SAY-5 @williamdes
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.