Title: Missing space before UNION when building CREATE VIEW · Issue #655 · phpmyadmin/sql-parser · GitHub
Open Graph Title: Missing space before UNION when building CREATE VIEW · Issue #655 · phpmyadmin/sql-parser
X Title: Missing space before UNION when building CREATE VIEW · Issue #655 · phpmyadmin/sql-parser
Description: 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 = 3un...
Open Graph Description: 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. Resul...
X Description: 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. Resul...
Opengraph URL: https://github.com/phpmyadmin/sql-parser/issues/655
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing space before UNION when building CREATE VIEW","articleBody":"## Summary\n\nWhen `CreateStatement::build()` reconstructs a `CREATE VIEW ... AS SELECT ... UNION ...`\nstatement, the output misses the whitespace between the built `SELECT` and the\ntrailing body tokens. Result: invalid SQL such as `... WHERE 3 = 3union all (...)`.\n\nThis was previously reported downstream in phpMyAdmin:\n- phpmyadmin/phpmyadmin#19692\n- phpmyadmin/phpmyadmin#18515 (same bug, older)\n\n## Reproduction\n\n```php\nuse PhpMyAdmin\\SqlParser\\Parser;\n\n$sql = \"CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER \"\n . \"VIEW `v1` AS select 1 AS `a` where 3 = 3 union all (select 2 AS `a`)\";\n\necho (new Parser($sql))->statements[0]->build();\n```\n\nActual output:\n```\nCREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS SELECT 1 AS `a` WHERE 3 = 3union all (select 2 AS `a`)\n```\n(note: `3 = 3union all` — no space).\n\nExpected: a space before `union all`, producing valid SQL.\n\n## Environment\n\n- Library version: current `master` (head `f440917e`)\n- PHP: 8.4","author":{"url":"https://github.com/predictor2718","@type":"Person","name":"predictor2718"},"datePublished":"2026-04-24T13:31:02Z","url":"https://github.com/phpmyadmin/sql-parser/issues/655"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7eab4dd0-f975-9401-3e5f-325ef5dfc11b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E356:21A483:193DE37:21E4D56:6B0436BB |
| html-safe-nonce | a3b71b0cd23907f453c5fd934dfbbe1ebf4e3d97c6d55781f221ab99f3e3f009 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzU2OjIxQTQ4MzoxOTNERTM3OjIxRTRENTY6NkIwNDM2QkIiLCJ2aXNpdG9yX2lkIjoiNzEwNjE1NzE3Njk2Mzc0MTM3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 06650eff467dbfb2214223e8ca1450e41eba6fd73f4147aaf38090117123d9ec |
| hovercard-subject-tag | issue:4323245975 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/phpmyadmin/sql-parser/655/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d7e7a07415fa9c197be04c236ef62fc8ec7703e65271dfbb01c0e95fbfa584f3/phpmyadmin/sql-parser/issues/655 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d7e7a07415fa9c197be04c236ef62fc8ec7703e65271dfbb01c0e95fbfa584f3/phpmyadmin/sql-parser/issues/655 |
| og:image:alt | 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. Resul... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | predictor2718 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/phpmyadmin/sql-parser git https://github.com/phpmyadmin/sql-parser.git |
| octolytics-dimension-user_id | 1351977 |
| octolytics-dimension-user_login | phpmyadmin |
| octolytics-dimension-repository_id | 36256604 |
| octolytics-dimension-repository_nwo | phpmyadmin/sql-parser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36256604 |
| octolytics-dimension-repository_network_root_nwo | phpmyadmin/sql-parser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width