Skip to content

Commit

Permalink
Issue #2042239 by lucaslg, tbradbury, snehi, pkiraly, pjonckiere, ori…
Browse files Browse the repository at this point in the history
…ol_e9g, ivanchaer, jhodgdon, chx, cilefen, David_Rothstein: Fix DeleteQuery::execute() return value documentation and DeleteQuery_sqlite documentation
  • Loading branch information
DavidRothstein committed Jun 6, 2017
1 parent 9480662 commit 8a09ddd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions includes/database/query.inc
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ class DeleteQuery extends Query implements QueryConditionInterface {
/**
* Executes the DELETE query.
*
* @return
* The return value is dependent on the database connection.
* @return int
* The number of rows affected by the delete query.
*/
public function execute() {
$values = array();
Expand Down
13 changes: 6 additions & 7 deletions includes/database/sqlite/query.inc
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,15 @@ class UpdateQuery_sqlite extends UpdateQuery {

/**
* SQLite specific implementation of DeleteQuery.
*
* When the WHERE is omitted from a DELETE statement and the table being deleted
* has no triggers, SQLite uses an optimization to erase the entire table content
* without having to visit each row of the table individually.
*
* Prior to SQLite 3.6.5, SQLite does not return the actual number of rows deleted
* by that optimized "truncate" optimization.
*/
class DeleteQuery_sqlite extends DeleteQuery {
public function execute() {
// When the WHERE is omitted from a DELETE statement and the table being
// deleted has no triggers, SQLite uses an optimization to erase the entire
// table content without having to visit each row of the table individually.
// Prior to SQLite 3.6.5, SQLite does not return the actual number of rows
// deleted by that optimized "truncate" optimization. But we want to return
// the number of rows affected, so we calculate it directly.
if (!count($this->condition)) {
$total_rows = $this->connection->query('SELECT COUNT(*) FROM {' . $this->connection->escapeTable($this->table) . '}')->fetchField();
parent::execute();
Expand Down

0 comments on commit 8a09ddd

Please sign in to comment.