Commit b9fc15d6 authored by alexpott's avatar alexpott

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
......@@ -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;
}
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment