mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-06 15:28:58 +01:00
Fixes #13577: yii\db\QueryBuilder::truncateTable should work consistent over all databases
This commit is contained in:
committed by
Alexander Makarov
parent
f496567735
commit
30b7fc8dc1
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user