From a9d9fa0ab5f8590c5e2bb8f6c297e394edd5dd78 Mon Sep 17 00:00:00 2001 From: michalsn Date: Fri, 28 Feb 2025 15:56:53 +0100 Subject: [PATCH 1/3] refactor: OCI8 limit() method --- system/Database/OCI8/Builder.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php index 5b586761e2c0..689169df71a7 100644 --- a/system/Database/OCI8/Builder.php +++ b/system/Database/OCI8/Builder.php @@ -214,19 +214,13 @@ protected function _update(string $table, array $values): string protected function _limit(string $sql, bool $offsetIgnore = false): string { $offset = (int) ($offsetIgnore === false ? $this->QBOffset : 0); - if (version_compare($this->db->getVersion(), '12.1', '>=')) { - // OFFSET-FETCH can be used only with the ORDER BY clause - if (empty($this->QBOrderBy)) { - $sql .= ' ORDER BY 1'; - } - return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY'; + // OFFSET-FETCH can be used only with the ORDER BY clause + if (empty($this->QBOrderBy)) { + $sql .= ' ORDER BY 1'; } - $this->limitUsed = true; - $limitTemplateQuery = 'SELECT * FROM (SELECT INNER_QUERY.*, ROWNUM RNUM FROM (%s) INNER_QUERY WHERE ROWNUM < %d)' . ($offset !== 0 ? ' WHERE RNUM >= %d' : ''); - - return sprintf($limitTemplateQuery, $sql, $offset + $this->QBLimit + 1, $offset); + return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY'; } /** From 1a5ba5b7c478feee7236db5783a1563c31760622 Mon Sep 17 00:00:00 2001 From: michalsn Date: Fri, 28 Feb 2025 16:19:29 +0100 Subject: [PATCH 2/3] remove the unused class property and method --- system/Database/OCI8/Builder.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/system/Database/OCI8/Builder.php b/system/Database/OCI8/Builder.php index 689169df71a7..2e62b3121cbd 100644 --- a/system/Database/OCI8/Builder.php +++ b/system/Database/OCI8/Builder.php @@ -48,16 +48,6 @@ class Builder extends BaseBuilder */ protected $countString = 'SELECT COUNT(1) '; - /** - * Limit used flag - * - * If we use LIMIT, we'll add a field that will - * throw off num_fields later. - * - * @var bool - */ - protected $limitUsed = false; - /** * A reference to the database connection. * @@ -223,15 +213,6 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string return $sql . ' OFFSET ' . $offset . ' ROWS FETCH NEXT ' . $this->QBLimit . ' ROWS ONLY'; } - /** - * Resets the query builder values. Called by the get() function - */ - protected function resetSelect() - { - $this->limitUsed = false; - parent::resetSelect(); - } - /** * Generates a platform-specific batch update string from the supplied data */ From 6ae1efe80369eace4dbf918df7da56a26f997c2d Mon Sep 17 00:00:00 2001 From: michalsn Date: Fri, 28 Feb 2025 16:22:11 +0100 Subject: [PATCH 3/3] phpstan - regenerate baseline --- utils/phpstan-baseline/missingType.return.neon | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/utils/phpstan-baseline/missingType.return.neon b/utils/phpstan-baseline/missingType.return.neon index baddb8644505..838443fab4f0 100644 --- a/utils/phpstan-baseline/missingType.return.neon +++ b/utils/phpstan-baseline/missingType.return.neon @@ -1,4 +1,4 @@ -# total 201 errors +# total 200 errors parameters: ignoreErrors: @@ -112,11 +112,6 @@ parameters: count: 1 path: ../../system/Database/MigrationRunner.php - - - message: '#^Method CodeIgniter\\Database\\OCI8\\Builder\:\:resetSelect\(\) has no return type specified\.$#' - count: 1 - path: ../../system/Database/OCI8/Builder.php - - message: '#^Method CodeIgniter\\Database\\Postgre\\Connection\:\:buildDSN\(\) has no return type specified\.$#' count: 1