-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ColumnSchema classes for performance of typecasting (#236)
- Loading branch information
Showing
7 changed files
with
144 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Oracle\Column; | ||
|
||
use Yiisoft\Db\Command\ParamInterface; | ||
use Yiisoft\Db\Expression\Expression; | ||
use Yiisoft\Db\Schema\Column\BinaryColumnSchema as BaseBinaryColumnSchema; | ||
|
||
use function is_string; | ||
|
||
final class BinaryColumnSchema extends BaseBinaryColumnSchema | ||
{ | ||
public function dbTypecast(mixed $value): mixed | ||
{ | ||
if ($this->getDbType() === 'BLOB') { | ||
if ($value instanceof ParamInterface && is_string($value->getValue())) { | ||
/** @var string */ | ||
$value = $value->getValue(); | ||
} | ||
|
||
if (is_string($value)) { | ||
return new Expression('TO_BLOB(UTL_RAW.CAST_TO_RAW(:value))', ['value' => $value]); | ||
} | ||
} | ||
|
||
return parent::dbTypecast($value); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Db\Oracle\Tests\Provider; | ||
|
||
use Yiisoft\Db\Oracle\Column\BinaryColumnSchema; | ||
|
||
class ColumnSchemaProvider extends \Yiisoft\Db\Tests\Provider\ColumnSchemaProvider | ||
{ | ||
public static function predefinedTypes(): array | ||
{ | ||
$values = parent::predefinedTypes(); | ||
$values['binary'][0] = BinaryColumnSchema::class; | ||
|
||
return $values; | ||
} | ||
|
||
public static function dbTypecastColumns(): array | ||
{ | ||
$values = parent::dbTypecastColumns(); | ||
$values['binary'][0] = BinaryColumnSchema::class; | ||
|
||
return $values; | ||
} | ||
} |