@@ -993,6 +993,12 @@ public function testUnions()
993
993
$ builder ->union ($ this ->getSqlServerBuilder ()->select ('name ' )->from ('users ' )->where ('id ' , '= ' , 2 ));
994
994
$ this ->assertEquals ($ expectedSql , $ builder ->toSql ());
995
995
$ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
996
+
997
+ $ builder = $ this ->getBuilder ();
998
+ $ eloquentBuilder = new EloquentBuilder ($ this ->getBuilder ());
999
+ $ builder ->select ('* ' )->from ('users ' )->where ('id ' , '= ' , 1 )->union ($ eloquentBuilder ->select ('* ' )->from ('users ' )->where ('id ' , '= ' , 2 ));
1000
+ $ this ->assertSame ('(select * from "users" where "id" = ?) union (select * from "users" where "id" = ?) ' , $ builder ->toSql ());
1001
+ $ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
996
1002
}
997
1003
998
1004
public function testUnionAlls ()
@@ -1009,6 +1015,13 @@ public function testUnionAlls()
1009
1015
$ builder ->unionAll ($ this ->getBuilder ()->select ('* ' )->from ('users ' )->where ('id ' , '= ' , 2 ));
1010
1016
$ this ->assertEquals ($ expectedSql , $ builder ->toSql ());
1011
1017
$ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
1018
+
1019
+ $ builder = $ this ->getBuilder ();
1020
+ $ eloquentBuilder = new EloquentBuilder ($ this ->getBuilder ());
1021
+ $ builder ->select ('* ' )->from ('users ' )->where ('id ' , '= ' , 1 );
1022
+ $ builder ->unionAll ($ eloquentBuilder ->select ('* ' )->from ('users ' )->where ('id ' , '= ' , 2 ));
1023
+ $ this ->assertSame ('(select * from "users" where "id" = ?) union all (select * from "users" where "id" = ?) ' , $ builder ->toSql ());
1024
+ $ this ->assertEquals ([0 => 1 , 1 => 2 ], $ builder ->getBindings ());
1012
1025
}
1013
1026
1014
1027
public function testMultipleUnions ()
0 commit comments