Commit b9fc15d6 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1806606 by daffie, Jorrit: Drupal\Core\Database\Query\Select::range()...

Issue #1806606 by daffie, Jorrit: Drupal\Core\Database\Query\Select::range() doesn't correctly implement SelectInterface
parent 731a0728
Loading
Loading
Loading
Loading
+1 −1
Changes for core/lib/Drupal/Core/Database/Query/Select.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -660,7 +660,7 @@ public function orderRandom() {
   * {@inheritdoc}
   */
  public function range($start = NULL, $length = NULL) {
    $this->range = func_num_args() ? array('start' => $start, 'length' => $length) : array();
    $this->range = $start !== NULL ? array('start' => $start, 'length' => $length) : array();
    return $this;
  }

+14 −0
Changes for core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -154,6 +154,20 @@ function testRange() {
    $this->assertEqual($query_result, 2, 'Returned the correct number of rows.');
  }

  /**
   * Test whether the range property of a select clause can be undone.
   */
  function testRangeUndo() {
    $query = db_select('test');
    $name_field = $query->addField('test', 'name');
    $age_field = $query->addField('test', 'age', 'age');
    $query->range(0, 2);
    $query->range(NULL, NULL);
    $query_result = $query->countQuery()->execute()->fetchField();

    $this->assertEqual($query_result, 4, 'Returned the correct number of rows.');
  }

  /**
   * Tests distinct queries.
   */