Skip to content

Commit

Permalink
SQL__Global类生成truncate语句时做了调整;
Browse files Browse the repository at this point in the history
  • Loading branch information
rainbowsoft committed Dec 5, 2024
1 parent cd87ca9 commit 9e99d14
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/phpunit/ClassSQL__MySQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public function tearDown(): void
self::$db = null;
}

public function testTruncate(): void
{
$this->assertEquals('TRUNCATE TABLE zbp_post ', self::$db->truncate("zbp_post")->sql);
}

public function testExist(): void
{
self::$db->exist('zbp_post', 'zbphp');
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/ClassSQL__PostgreSQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function testExist()
$this->assertEquals('SELECT COUNT(*) FROM information_schema.tables WHERE table_schema=\'public\' AND table_name =\'zbp_post\'', self::$db->sql);
}

public function testTruncate(): void
{
$this->assertEquals('TRUNCATE TABLE zbp_post ', self::$db->truncate("zbp_post")->sql);
}

public function testIndex()
{
self::$db->create('zbp_post')->index(array('indexname' => array('ddd', 'eee', 'eeee')));
Expand Down
5 changes: 5 additions & 0 deletions tests/phpunit/ClassSQL__SQLiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public function testExist()
$this->assertEquals('SELECT COUNT(*) FROM sqlite_master WHERE type=\'table\' AND name=\'zbp_post\'', self::$db->sql);
}

public function testTruncate(): void
{
$this->assertEquals('DELETE FROM zbp_post ', self::$db->truncate("zbp_post")->sql);
}

public function testIndex()
{
self::$db->create('zbp_post')->index(array('indexname' => array('ddd', 'eee', 'eeee')));
Expand Down
7 changes: 6 additions & 1 deletion zb_system/function/lib/sql/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,12 @@ protected function buildInsert()
protected function buildTRUNCATE()
{
$sql = &$this->pri_sql;
$sql[] = 'TABLE';
if (get_class($this) == 'SQL__SQLite') {
$sql = array('DELETE');
$sql[] = 'FROM';
} else {
$sql[] = 'TABLE';
}
$this->buildTable();
}

Expand Down

0 comments on commit 9e99d14

Please sign in to comment.