diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index b7f1f32..7092acc 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -520,7 +520,7 @@ protected function filterComment($comment = '') { * An associative array of options to control how the query is run. See * the documentation for DatabaseConnection::defaultOptions() for details. * - * @return \Drupal\Core\Database\StatementInterface + * @return \Drupal\Core\Database\StatementInterface|int|null * This method will return one of: the executed statement, the number of * rows affected by the query (not the number matched), or the generated * insert ID of the last query, depending on the value of @@ -570,6 +570,9 @@ public function query($query, array $args = array(), $options = array()) { } } catch (\PDOException $e) { + // Most database drivers will return NULL here, but some of them + // (e.g. the SQLite driver) may need to re-run the query, so the return + // value will be the same as for static::query(). return $this->handleQueryException($e, $query, $args, $options); } } @@ -586,7 +589,10 @@ public function query($query, array $args = array(), $options = array()) { * @param array $options * An associative array of options to control how the query is run. * - * @return null + * @return \Drupal\Core\Database\StatementInterface|int|null + * Most database drivers will return NULL when a PDO exception is thrown for + * a query, but some of them may need to re-run the query, so they can also + * return a \Drupal\Core\Database\StatementInterface object or an integer. * * @throws \Drupal\Core\Database\DatabaseExceptionWrapper * @throws \Drupal\Core\Database\IntegrityConstraintViolationException