From 58382757ae4968b801b5eb25b03212d96975d0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 23 Jan 2022 00:35:56 +0100 Subject: [PATCH] Drop Oracle 11g support --- src/Persistence/Sql/Oracle/Query.php | 64 ++++------------------------ 1 file changed, 9 insertions(+), 55 deletions(-) diff --git a/src/Persistence/Sql/Oracle/Query.php b/src/Persistence/Sql/Oracle/Query.php index 5c8ebf855..37b658edf 100644 --- a/src/Persistence/Sql/Oracle/Query.php +++ b/src/Persistence/Sql/Oracle/Query.php @@ -97,70 +97,24 @@ protected function _sub_render_condition(array $row): string return parent::_sub_render_condition($row); } - public function groupConcat($field, string $delimiter = ',') - { - return $this->expr('listagg({field}, []) within group (order by {field})', ['field' => $field, $delimiter]); - } - - // {{{ for Oracle 11 and lower to support LIMIT with OFFSET - - protected $template_select = '[with]select[option] [field] [from] [table][join][where][group][having][order]'; - /** @var string */ - protected $template_select_limit = 'select * from (select "__t".*, rownum "__dsql_rownum" [from] ([with]select[option] [field] [from] [table][join][where][group][having][order]) "__t") where "__dsql_rownum" > [limit_start][and_limit_end]'; - - public function limit($cnt, $shift = null) - { - $this->template_select = $this->template_select_limit; - - return parent::limit($cnt, $shift); - } - - public function _render_limit_start(): string - { - return (string) ($this->args['limit']['shift'] ?? 0); - } - - public function _render_and_limit_end(): ?string + public function _render_limit(): ?string { - if (!$this->args['limit']['cnt']) { - return ''; + if (!isset($this->args['limit'])) { + return null; } - return ' and "__dsql_rownum" <= ' - . max((int) ($this->args['limit']['cnt'] + $this->args['limit']['shift']), (int) $this->args['limit']['cnt']); - } - - public function getRowsIterator(): \Traversable - { - foreach (parent::getRowsIterator() as $row) { - unset($row['__dsql_rownum']); - - yield $row; - } - } - - public function getRows(): array - { - return array_map(function ($row) { - unset($row['__dsql_rownum']); + $cnt = (int) $this->args['limit']['cnt']; + $shift = (int) $this->args['limit']['shift']; - return $row; - }, parent::getRows()); + return ($shift ? ' offset ' . $shift . ' rows' : '') + . ($cnt ? ' fetch next ' . $cnt . ' rows only' : ''); } - public function getRow(): ?array + public function groupConcat($field, string $delimiter = ',') { - $row = parent::getRow(); - - if ($row !== null) { - unset($row['__dsql_rownum']); - } - - return $row; + return $this->expr('listagg({field}, []) within group (order by {field})', ['field' => $field, $delimiter]); } - /// }}} - public function exists() { return $this->dsql()->mode('select')->field(