diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 2a75844..cb5a61f 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1048,11 +1048,15 @@ function node_query_node_access_alter(AlterableInterface $query) {
   $base_table = $query->getMetaData('base_table');
   // If the base table is not given, default to node if present.
   if (!$base_table) {
+    /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
+    $table_mapping = \Drupal::entityTypeManager()->getStorage('node')->getTableMapping();
+    $node_base_tables = $table_mapping->getTableNames();
+
     foreach ($tables as $table_info) {
       if (!($table_info instanceof SelectInterface)) {
         $table = $table_info['table'];
-        // If the node table is in the query, it wins immediately.
-        if ($table == 'node' || $table == 'node_field_data') {
+        // If one of the node base tables are in the query, it wins immediately.
+        if (in_array($table, $node_base_tables)) {
           $base_table = $table;
           break;
         }
diff --git a/core/modules/node/src/Tests/NodeQueryAlterTest.php b/core/modules/node/src/Tests/NodeQueryAlterTest.php
index d0d615e..e38db17 100644
--- a/core/modules/node/src/Tests/NodeQueryAlterTest.php
+++ b/core/modules/node/src/Tests/NodeQueryAlterTest.php
@@ -73,6 +73,24 @@ function testNodeQueryAlterLowLevelWithAccess() {
   }
 
   /**
+   * Tests 'node_access' query alter with revision-enabled nodes.
+   */
+  public function testNodeQueryAlterWithRevisions() {
+    // Execute a query that only deals with the 'node_revision' table.
+    try {
+      $query = \Drupal::entityTypeManager()->getStorage('node')->getQuery();
+      $result = $query
+        ->allRevisions()
+        ->execute();
+
+      $this->assertEqual(count($result), 4, 'User with access can see correct nodes');
+    }
+    catch (\Exception $e) {
+      $this->fail(t('Altered query is malformed'));
+    }
+  }
+
+  /**
    * Tests 'node_access' query alter, for user without access.
    *
    * Verifies that a non-standard table alias can be used, and that a user
