Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ jobs:

- name: Run infection.
run: |
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations --only-covered
vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ignore-msi-with-no-mutations
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- Enh #359: Update `DMLQueryBuilder::update()` method to adapt changes in `yiisoft/db` (@rustamwin)
- Enh #373: Adapt to `DQLQueryBuilderInterface::buildWithQueries()` signature changes in `yiisoft/db` package (@vjik)
- Chg #378: Throw exception on "unsigned" column usage (@vjik)
- Chg #381: Refactor `ColumnDefinitionParser` (@vjik)

## 1.3.0 March 21, 2024

Expand Down
37 changes: 30 additions & 7 deletions src/Column/ColumnDefinitionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Yiisoft\Db\Oracle\Column;

use Yiisoft\Db\Syntax\AbstractColumnDefinitionParser;

use function preg_match;
use function preg_replace;
use function strlen;
Expand All @@ -13,7 +15,7 @@
/**
* Parses column definition string. For example, `string(255)` or `int unsigned`.
*/
final class ColumnDefinitionParser extends \Yiisoft\Db\Syntax\ColumnDefinitionParser
final class ColumnDefinitionParser extends AbstractColumnDefinitionParser
{
private const TYPE_PATTERN = '/^('
. 'timestamp\s*(?:\((\d+)\))? with(?: local)? time zone'
Expand All @@ -37,11 +39,7 @@ public function parse(string $definition): array
$typeDetails = $matches[6] ?? $matches[2] ?? '';

if ($typeDetails !== '') {
if ($type === 'enum') {
$info += $this->enumInfo($typeDetails);
} else {
$info += $this->sizeInfo($typeDetails);
}
$info += $this->parseSizeInfo($typeDetails);
}

$scale = $matches[5] ?? $matches[3] ?? '';
Expand All @@ -57,6 +55,31 @@ public function parse(string $definition): array

$extra = substr($definition, strlen($matches[0]));

return $info + $this->extraInfo($extra);
if ($extra !== '') {
$info += $this->extraInfo($extra);
}

return $info;
}

protected function parseTypeParams(string $type, string $params): array
{
return match ($type) {
'char',
'nchar',
'character',
'varchar',
'varchar2',
'nvarchar2',
'raw',
'number',
'float',
'timestamp',
'timestamp with time zone',
'timestamp with local time zone',
'interval day to second',
'interval year to month' => $this->parseSizeInfo($params),
default => [],
};
}
}
Loading