Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Query / Sql / Query.php
index cd245ef7b5284511a979f00ea05ef217b661783d..7e5db5b9a05cb7214961ea2822307c13cbec9151 100644 (file)
@@ -64,7 +64,6 @@ class Query extends QueryBase implements QueryInterface {
     $this->connection = $connection;
   }
 
-
   /**
    * {@inheritdoc}
    */
@@ -119,6 +118,14 @@ class Query extends QueryBase implements QueryInterface {
       // entity id.
       $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field];
     }
+
+    // Add a self-join to the base revision table if we're querying only the
+    // latest revisions.
+    if ($this->latestRevision && $revision_field) {
+      $this->sqlQuery->leftJoin($base_table, 'base_table_2', "base_table.$id_field = base_table_2.$id_field AND base_table.$revision_field < base_table_2.$revision_field");
+      $this->sqlQuery->isNull("base_table_2.$id_field");
+    }
+
     if ($this->accessCheck) {
       $this->sqlQuery->addTag($this->entityTypeId . '_access');
     }