File tree Expand file tree Collapse file tree
tests/system/Database/Builder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2803,9 +2803,9 @@ protected function _truncate(string $table): string
28032803 */
28042804 public function getCompiledDelete (bool $ reset = true ): string
28052805 {
2806- $ table = $ this ->QBFrom [ 0 ] ;
2807-
2808- $ sql = $ this ->delete ( $ table , null , $ reset );
2806+ $ this ->testMode () ;
2807+ $ sql = $ this -> delete ( '' , null , $ reset );
2808+ $ this ->testMode ( false );
28092809
28102810 return $ this ->compileFinalQuery ($ sql );
28112811 }
Original file line number Diff line number Diff line change @@ -35,4 +35,28 @@ public function testDelete()
3535 $ this ->assertEquals ($ expectedBinds , $ builder ->getBinds ());
3636 }
3737
38+ public function testGetCompiledDelete ()
39+ {
40+ $ builder = $ this ->db ->table ('jobs ' );
41+
42+ $ builder ->where ('id ' , 1 );
43+ $ sql = $ builder ->getCompiledDelete ();
44+
45+ $ expectedSQL = 'DELETE FROM "jobs" '
46+ . "\n" . 'WHERE "id" = 1 ' ;
47+ $ this ->assertEquals ($ expectedSQL , $ sql );
48+ }
49+
50+ public function testGetCompiledDeleteWithLimit ()
51+ {
52+ $ builder = $ this ->db ->table ('jobs ' );
53+
54+ $ builder ->where ('id ' , 1 );
55+ $ builder ->limit (10 );
56+ $ sql = $ builder ->getCompiledDelete ();
57+
58+ $ expectedSQL = 'DELETE FROM "jobs" '
59+ . "\n" . 'WHERE "id" = 1 LIMIT 10 ' ;
60+ $ this ->assertEquals ($ expectedSQL , $ sql );
61+ }
3862}
You can’t perform that action at this time.
0 commit comments