Skip to content
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- Enh #279: Separate column type constants (@Tigrov)
- New #280, #291: Realize `ColumnBuilder` class (@Tigrov)
- Enh #281: Update according changes in `ColumnSchemaInterface` (@Tigrov)
- New #282, #291, #299: Add `ColumnDefinitionBuilder` class (@Tigrov)
- New #282, #291, #299, #302: Add `ColumnDefinitionBuilder` class (@Tigrov)
- Bug #285: Fix `DMLQueryBuilder::insertBatch()` method (@Tigrov)
- Enh #283: Refactor `Dsn` class (@Tigrov)
- Enh #286: Use constructor to create columns and initialize properties (@Tigrov)
Expand Down
5 changes: 3 additions & 2 deletions src/Column/ColumnDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Yiisoft\Db\Oracle\Column;

use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\ReferentialAction;
use Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder;
use Yiisoft\Db\Schema\Column\ColumnInterface;

Expand Down Expand Up @@ -51,8 +52,8 @@ public function build(ColumnInterface $column): string
protected function buildOnDelete(string $onDelete): string
{
return match ($onDelete = strtoupper($onDelete)) {
'CASCADE',
'SET NULL' => " ON DELETE $onDelete",
ReferentialAction::CASCADE,
ReferentialAction::SET_NULL => " ON DELETE $onDelete",
default => '',
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Throwable;
use Yiisoft\Db\Cache\SchemaCache;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Constant\ReferentialAction;
use Yiisoft\Db\Constraint\CheckConstraint;
use Yiisoft\Db\Constraint\Constraint;
use Yiisoft\Db\Constraint\ForeignKeyConstraint;
Expand Down Expand Up @@ -58,8 +59,7 @@
* foreign_table_schema: string|null,
* foreign_table_name: string|null,
* foreign_column_name: string|null,
* on_update: string,
* on_delete: string,
* on_delete: ReferentialAction::*,
* check_expr: string
* }
* >
Expand Down
7 changes: 5 additions & 2 deletions tests/Provider/QueryBuilderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Exception;
use Yiisoft\Db\Constant\ColumnType;
use Yiisoft\Db\Constant\PseudoType;
use Yiisoft\Db\Constant\ReferentialAction;
use Yiisoft\Db\Constraint\ForeignKeyConstraint;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Oracle\Column\ColumnBuilder;
Expand Down Expand Up @@ -243,10 +244,12 @@ public static function buildColumnDefinition(): array
$referenceRestrict = new ForeignKeyConstraint();
$referenceRestrict->foreignColumnNames(['id']);
$referenceRestrict->foreignTableName('ref_table');
$referenceRestrict->onDelete('restrict');
$referenceRestrict->onDelete(ReferentialAction::RESTRICT);
$referenceRestrict->onUpdate(ReferentialAction::RESTRICT);

$referenceSetNull = clone $referenceRestrict;
$referenceSetNull->onDelete('set null');
$referenceSetNull->onDelete(ReferentialAction::SET_NULL);
$referenceRestrict->onUpdate(ReferentialAction::SET_NULL);

$values = parent::buildColumnDefinition();

Expand Down