Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Oracle 11g support #964

Merged
merged 4 commits into from
Jan 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
@@ -111,9 +111,9 @@ jobs:
ACCEPT_EULA: Y
SA_PASSWORD: atk4_pass
oracle:
image: ghcr.io/mvorisek/docker-oracle-xe-11g
image: gvenzl/oracle-xe:18
env:
ORACLE_ALLOW_REMOTE: true
ORACLE_PASSWORD: atk4_pass
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -218,23 +218,21 @@ jobs:
env:
DB_DSN: "pdo_oci:dbname=oracle/xe"
DB_USER: system
DB_PASSWORD: oracle
DB_PASSWORD: atk4_pass
NLS_LANG: AMERICAN_AMERICA.AL32UTF8
run: |
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v \
|| php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v
if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-oracle-pdo.cov; fi

- name: "Run tests: Oracle - OCI8 (only for coverage or cron)"
if: env.LOG_COVERAGE || github.event_name == 'schedule'
env:
DB_DSN: "oci8:dbname=oracle/xe"
DB_USER: system
DB_PASSWORD: oracle
DB_PASSWORD: atk4_pass
NLS_LANG: AMERICAN_AMERICA.AL32UTF8
run: |
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v \
|| php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v
php -d opcache.enable_cli=1 vendor/bin/phpunit --exclude-group none $(if [ -n "$LOG_COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi) -v
if [ -n "$LOG_COVERAGE" ]; then mv coverage/phpunit.cov coverage/phpunit-oracle-oci8.cov; fi

- name: Upload coverage logs 1/2 (only for latest Phpunit)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@
"require-release": {
"php": ">=7.4 <8.2",
"atk4/core": "~3.2.0",
"doctrine/dbal": "^3.š",
"doctrine/dbal": "^3.3",
"mvorisek/atk4-hintable": "~1.7.1"
},
"require-dev": {
2 changes: 1 addition & 1 deletion src/Persistence/Sql/Connection.php
Original file line number Diff line number Diff line change
@@ -316,7 +316,7 @@ public function connection()
public function execute(Expression $expr): DbalResult
{
if ($this->connection === null) {
throw new Exception('Queries cannot be executed through this connection');
throw new Exception('DBAL connection is not set');
}

return $expr->execute($this->connection);
64 changes: 9 additions & 55 deletions src/Persistence/Sql/Oracle/Query.php
Original file line number Diff line number Diff line change
@@ -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(