summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-07-20 12:13:28 (GMT)
committerAlex Pott2016-07-20 12:13:28 (GMT)
commitb9fc15d6225366e7580adf8c5fc3240dbf865632 (patch)
tree42d257a74877c5237e9ef26cfefa78849fac6e34
parent731a0728b5d220526651ea97210128efb968d4a0 (diff)
Issue #1806606 by daffie, Jorrit: Drupal\Core\Database\Query\Select::range() doesn't correctly implement SelectInterface
-rw-r--r--core/lib/Drupal/Core/Database/Query/Select.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php14
2 files changed, 15 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php
index b269410..a5e93e8 100644
--- a/core/lib/Drupal/Core/Database/Query/Select.php
+++ b/core/lib/Drupal/Core/Database/Query/Select.php
@@ -660,7 +660,7 @@ class Select extends Query implements SelectInterface {
* {@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;
}
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
index ccf153b..d6da254 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
@@ -155,6 +155,20 @@ class SelectComplexTest extends DatabaseTestBase {
}
/**
+ * 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.
*/
function testDistinct() {