Skip to content

Commit c629081

Browse files
authored
[3.x] Use row_number window function on MariaDB >= 11.0 (#300)
Appveyor fail is unrelated
1 parent 133e3d0 commit c629081

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Query/MysqlQueryBuilder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,18 @@ public function findInSet($value, $set)
210210
*
211211
* @since 2.0.0
212212
* @throws \RuntimeException
213+
*
214+
* @todo Remove this method when the database version requirements have been raised
215+
* to >= 8.0.0 for MySQL and >= 10.2.0 for MariaDB so the ROW_NUMBER() window
216+
* function can be used in any case.
213217
*/
214218
public function selectRowNumber($orderBy, $orderColumnAlias)
215219
{
220+
// Use parent method with ROW_NUMBER() window function on MariaDB 11.0.0 and newer.
221+
if ($this->db->isMariaDb() && version_compare($this->db->getVersion(), '11.0.0', '>=')) {
222+
return parent::selectRowNumber($orderBy, $orderColumnAlias);
223+
}
224+
216225
$this->validateRowNumber($orderBy, $orderColumnAlias);
217226

218227
return $this->select("(SELECT @rownum := @rownum + 1 FROM (SELECT @rownum := 0) AS r) AS $orderColumnAlias");

0 commit comments

Comments
 (0)