Skip to content

Commit

Permalink
allow full 255 bytes for binary DBAL type for Oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Nov 22, 2021
1 parent c40e26b commit dac8152
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/Persistence/Sql/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,10 @@ public function execute(object $connection = null): object
$type = ParameterType::STRING;

if ($platform instanceof PostgreSQL94Platform
|| $platform instanceof SQLServer2012Platform
|| $platform instanceof OraclePlatform) {
|| $platform instanceof SQLServer2012Platform) {
$dummyPersistence = new Persistence\Sql($this->connection);
if (\Closure::bind(fn () => $dummyPersistence->binaryTypeValueIsEncoded($val), null, Persistence\Sql::class)()) {
if (!$platform instanceof OraclePlatform) {
$val = \Closure::bind(fn () => $dummyPersistence->binaryTypeValueDecode($val), null, Persistence\Sql::class)();
}
$val = \Closure::bind(fn () => $dummyPersistence->binaryTypeValueDecode($val), null, Persistence\Sql::class)();
$type = ParameterType::BINARY;
}
}
Expand All @@ -552,8 +549,7 @@ public function execute(object $connection = null): object
->addMoreInfo('type', gettype($val));
}

if (is_string($val) && $platform instanceof OraclePlatform
&& ($type === ParameterType::BINARY || strlen($val) > 2000)) {
if (is_string($val) && $platform instanceof OraclePlatform && strlen($val) > 2000) {
$valRef = $val;
$bind = $statement->bindParam($key, $valRef, ParameterType::STRING, strlen($val));
unset($valRef);
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/Sql/Oracle/PlatformTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trait PlatformTrait

protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed)
{
return $this->getVarcharTypeDeclarationSQLSnippet($length, $fixed);
return $this->getClobTypeDeclarationSQL([]);
}

public function getBlobTypeDeclarationSQL(array $column)
Expand Down
4 changes: 2 additions & 2 deletions src/Persistence/Sql/Oracle/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ protected function _sub_render_condition(array $row): string
}

if (count($row) >= 2 && $field instanceof Field
&& in_array($field->getTypeObject()->getName(), ['text', 'blob'], true)) {
&& in_array($field->getTypeObject()->getName(), ['binary', 'text', 'blob'], true)) {
$value = $this->castStringToClobExpr($value);

if ($field->getTypeObject()->getName() !== 'blob') {
if ($field->getTypeObject()->getName() === 'text') {
$field = $this->expr('LOWER([])', [$field]);
$value = $this->expr('LOWER([])', [$value]);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Schema/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ public function providerCharacterTypeFieldLongData(): array
return [
['string', false, 250],
['binary', true, 250],
['text', false, 250],
['blob', true, 250],
['text', false, 256 * 1024],
['blob', true, 256 * 1024],
];
Expand Down

0 comments on commit dac8152

Please sign in to comment.