You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing space before UNION when building CREATE VIEW #655
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:
usePhpMyAdmin\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 (newParser($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.
Activity