@@ -921,27 +921,20 @@ public function testBuildCreateTableWithUppercaseHexDefault(): void
921921 }
922922
923923 /**
924- * Regression for #655: `CREATE VIEW ... AS SELECT ... WHERE ... UNION ALL (...)`
925- * used to lose the whitespace between the SELECT body and the trailing
926- * UNION clause, producing invalid SQL like `WHERE 3 = 3union all (...)`.
924+ * Regression for #655: the UNION body used to be glued to the SELECT,
925+ * producing invalid SQL like `WHERE 3 = 3union all (...)`.
927926 */
928927 public function testBuilderViewWithUnionPreservesWhitespace (): void
929928 {
930- $ sql = "CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER "
931- . "VIEW `v1` AS select 1 AS `a` where 3 = 3 union all (select 2 AS `a`) " ;
932-
933- $ parser = new Parser ($ sql );
934- $ built = $ parser ->statements [0 ]->build ();
935-
936- $ this ->assertStringNotContainsString (
937- '3union all ' ,
938- $ built ,
939- 'rebuilt CREATE VIEW must keep the space between WHERE clause and UNION ' ,
929+ $ parser = new Parser (
930+ 'CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER '
931+ . 'VIEW `v1` AS select 1 AS `a` where 3 = 3 union all (select 2 AS `a`) ' ,
940932 );
941- $ this ->assertStringContainsString (
942- '3 union all ' ,
943- // case-insensitive match: builder may upper-case the keyword
944- preg_replace ('/UNION\s+ALL/i ' , 'union all ' , $ built ),
933+
934+ $ this ->assertEquals (
935+ 'CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER '
936+ . 'VIEW `v1` AS SELECT 1 AS `a` WHERE 3 = 3 union all (select 2 AS `a`) ' ,
937+ $ parser ->statements [0 ]->build (),
945938 );
946939 }
947940}
0 commit comments