File tree 2 files changed +18
-1
lines changed
src/Illuminate/Database/Query/Grammars 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -387,7 +387,7 @@ protected function compileDeleteWithJoinsOrLimit(Builder $query)
387
387
public function compileTruncate (Builder $ query )
388
388
{
389
389
return [
390
- 'delete from sqlite_sequence where name = ? ' => [$ query ->from ],
390
+ 'delete from sqlite_sequence where name = ? ' => [$ this -> getTablePrefix (). $ query ->from ],
391
391
'delete from ' .$ this ->wrapTable ($ query ->from ) => [],
392
392
];
393
393
}
Original file line number Diff line number Diff line change @@ -3592,6 +3592,23 @@ public function testTruncateMethod()
3592
3592
], $ sqlite ->compileTruncate ($ builder ));
3593
3593
}
3594
3594
3595
+ public function testTruncateMethodWithPrefix ()
3596
+ {
3597
+ $ builder = $ this ->getBuilder ();
3598
+ $ builder ->getGrammar ()->setTablePrefix ('prefix_ ' );
3599
+ $ builder ->getConnection ()->shouldReceive ('statement ' )->once ()->with ('truncate table "prefix_users" ' , []);
3600
+ $ builder ->from ('users ' )->truncate ();
3601
+
3602
+ $ sqlite = new SQLiteGrammar ;
3603
+ $ sqlite ->setTablePrefix ('prefix_ ' );
3604
+ $ builder = $ this ->getBuilder ();
3605
+ $ builder ->from ('users ' );
3606
+ $ this ->assertEquals ([
3607
+ 'delete from sqlite_sequence where name = ? ' => ['prefix_users ' ],
3608
+ 'delete from "prefix_users" ' => [],
3609
+ ], $ sqlite ->compileTruncate ($ builder ));
3610
+ }
3611
+
3595
3612
public function testPreserveAddsClosureToArray ()
3596
3613
{
3597
3614
$ builder = $ this ->getBuilder ();
You can’t perform that action at this time.
0 commit comments