Fixes #13577: yii\db\QueryBuilder::truncateTable should work consistent over all databases

This commit is contained in:
Bob Olde Hampsink
2017-02-20 21:38:50 +01:00
committed by Alexander Makarov
parent f496567735
commit 30b7fc8dc1
10 changed files with 20 additions and 8 deletions

View File

@@ -205,6 +205,17 @@ class QueryBuilder extends \yii\db\QueryBuilder
return $command;
}
/**
* Builds a SQL statement for truncating a DB table.
* Explicitly restarts identity for PGSQL to be consistent with other databases which all do this by default.
* @param string $table the table to be truncated. The name will be properly quoted by the method.
* @return string the SQL statement for truncating a DB table.
*/
public function truncateTable($table)
{
return 'TRUNCATE TABLE ' . $this->db->quoteTableName($table) . ' RESTART IDENTITY';
}
/**
* Builds a SQL statement for changing the definition of a column.
* @param string $table the table whose column is to be changed. The table name will be properly quoted by the method.