diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
index 1ba5d1a74b..1826397c2b 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php
@@ -175,6 +175,29 @@ public function testInsertSelectFields() {
     $this->assertSame('30', $saved_age, 'Can retrieve after inserting.');
   }
 
+  /**
+   * Tests INSERT INTO ... SELECT (fields) ... with ORDER BY.
+   */
+  function testInsertSelectFieldsOrderby() {
+    $query = $this->connection->select('test', 't')
+      ->fields('t', ['name', 'job', 'age'])
+      ->condition('t.name', 'John')
+      ->orderBy('t.id');
+
+    // The resulting query should be equivalent to:
+    // INSERT INTO test_people (age, name, job)
+    // SELECT t.age AS age, t.name AS name, t.job AS job
+    // FROM test t
+    // WHERE t.name = 'John'
+    // ORDER BY t.id
+    $this->connection->insert('test_people')
+      ->from($query)
+      ->execute();
+
+    $saved_age = $this->connection->query('SELECT age FROM {test_people} WHERE name = :name', [':name' => 'John'])->fetchField();
+    $this->assertIdentical($saved_age, '25', 'Can retrieve after inserting.');
+  }
+
   /**
    * Tests that the INSERT INTO ... SELECT * ... syntax works.
    */
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
index fe85345d9b..1d44a23bc1 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
@@ -426,6 +426,19 @@ public function testUnionOrderLimit() {
     $this->assertEquals('Paul', $names[1], 'Second query returned correct name.');
   }
 
+  /**
+   * Tests that we can ORDER BY a column that is not in SELECT.
+   */
+  function testOrderbyColumnNotInSelect() {
+    $ordered_names = $this->connection->select('test', 't')
+      ->fields('t', ['name'])
+      ->orderBy('t.age')
+      ->execute()
+      ->fetchCol();
+
+    $this->assertEqual($ordered_names, ['John', 'Paul', 'George', 'Ringo'], 'A query with ordering names in the correct order, where the ordering column is not in the select.');
+  }
+
   /**
    * Tests that random ordering of queries works.
    *
