Skip to content

Commit 5838275

Browse files
committed
Drop Oracle 11g support
1 parent fb4039a commit 5838275

File tree

1 file changed

+9
-55
lines changed

1 file changed

+9
-55
lines changed

src/Persistence/Sql/Oracle/Query.php

+9-55
Original file line numberDiff line numberDiff line change
@@ -97,70 +97,24 @@ protected function _sub_render_condition(array $row): string
9797
return parent::_sub_render_condition($row);
9898
}
9999

100-
public function groupConcat($field, string $delimiter = ',')
101-
{
102-
return $this->expr('listagg({field}, []) within group (order by {field})', ['field' => $field, $delimiter]);
103-
}
104-
105-
// {{{ for Oracle 11 and lower to support LIMIT with OFFSET
106-
107-
protected $template_select = '[with]select[option] [field] [from] [table][join][where][group][having][order]';
108-
/** @var string */
109-
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]';
110-
111-
public function limit($cnt, $shift = null)
112-
{
113-
$this->template_select = $this->template_select_limit;
114-
115-
return parent::limit($cnt, $shift);
116-
}
117-
118-
public function _render_limit_start(): string
119-
{
120-
return (string) ($this->args['limit']['shift'] ?? 0);
121-
}
122-
123-
public function _render_and_limit_end(): ?string
100+
public function _render_limit(): ?string
124101
{
125-
if (!$this->args['limit']['cnt']) {
126-
return '';
102+
if (!isset($this->args['limit'])) {
103+
return null;
127104
}
128105

129-
return ' and "__dsql_rownum" <= '
130-
. max((int) ($this->args['limit']['cnt'] + $this->args['limit']['shift']), (int) $this->args['limit']['cnt']);
131-
}
132-
133-
public function getRowsIterator(): \Traversable
134-
{
135-
foreach (parent::getRowsIterator() as $row) {
136-
unset($row['__dsql_rownum']);
137-
138-
yield $row;
139-
}
140-
}
141-
142-
public function getRows(): array
143-
{
144-
return array_map(function ($row) {
145-
unset($row['__dsql_rownum']);
106+
$cnt = (int) $this->args['limit']['cnt'];
107+
$shift = (int) $this->args['limit']['shift'];
146108

147-
return $row;
148-
}, parent::getRows());
109+
return ($shift ? ' offset ' . $shift . ' rows' : '')
110+
. ($cnt ? ' fetch next ' . $cnt . ' rows only' : '');
149111
}
150112

151-
public function getRow(): ?array
113+
public function groupConcat($field, string $delimiter = ',')
152114
{
153-
$row = parent::getRow();
154-
155-
if ($row !== null) {
156-
unset($row['__dsql_rownum']);
157-
}
158-
159-
return $row;
115+
return $this->expr('listagg({field}, []) within group (order by {field})', ['field' => $field, $delimiter]);
160116
}
161117

162-
/// }}}
163-
164118
public function exists()
165119
{
166120
return $this->dsql()->mode('select')->field(

0 commit comments

Comments
 (0)