Change record status: 
Project: 
Introduced in branch: 
11.4.x
Introduced in version: 
11.4.0
Description: 

A new Select::getRange() method has been added to the database query API. This allows retrieving the currently configured range (start and length) from a Select query object.

Previously, there was no supported way to inspect the range applied to a query after calling range(). This made it difficult for query extenders and integrations to adjust behavior based on the existing range configuration.

The following methods were added:

\Drupal\Core\Database\Query\SelectInterface::getRange()

\Drupal\Core\Database\Query\Select::getRange()

\Drupal\Core\Database\Query\SelectExtender::getRange()

The method returns an array with start and length keys, or NULL if no range is set.

Before/After code examples

$query = $connection->select('node', 'n');
$query->range(0, 10);

// No supported way to retrieve the range.
$query = $connection->select('node', 'n');
$query->range(0, 10);

$range = $query->getRange();
// ['start' => 0, 'length' => 10]
Impacts: 
Module developers