diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
index edd54f3..137e23c 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php
@@ -310,11 +310,13 @@ public function nextId($existing_id = 0) {
     // override nextId. However, this is unlikely as we deal with short strings
     // and integers and no known databases require special handling for those
     // simple cases. If another transaction wants to write the same row, it will
-    // wait until this transaction commits.
-    $stmt = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', array(
+    // wait until this transaction commits. Also, the return value needs to be
+    // set to RETURN_AFFECTED as if it were a real update() query otherwise it
+    // is not possible to get the row count properly.
+    $affected = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', array(
       ':existing_id' => $existing_id,
-    ));
-    if (!$stmt->rowCount()) {
+    ), array('return' => Database::RETURN_AFFECTED));
+    if (!$affected) {
       $this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', array(
         ':existing_id' => $existing_id,
       ));
