Skip to content
Draft
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
10 changes: 10 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,4 +723,14 @@
{
return $this->attributes['fetchModeSubselectBatchSize'] ?? 100;
}

public function setDefaultStringTypeSchemaLength(int|null $length = null): void
{
$this->attributes['defaultStringTypeSchemaLength'] = $length;
}

public function getDefaultStringTypeSchemaLength(): ?int

Check failure on line 732 in src/Configuration.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (PHP: 8.4)

Usage of short nullable type hint in "?int" is disallowed.
{
return $this->attributes['defaultStringTypeSchemaLength'] ?? 255;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can never return null Setting null through the setter is not respected by the getter.

}
}
5 changes: 3 additions & 2 deletions src/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@

if (strtolower($discrColumn->type) === 'string' && ! isset($discrColumn->length)) {
$discrColumn->type = 'string';
$discrColumn->length = 255;
$discrColumn->length = $this->em->getConfiguration()->getDefaultStringTypeSchemaLength();
}

$options = [
Expand Down Expand Up @@ -454,8 +454,9 @@
$columnName = $this->quoteStrategy->getColumnName($mapping->fieldName, $class, $this->platform);
$columnType = $mapping->type;

$options = [];

Check failure on line 457 in src/Tools/SchemaTool.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (PHP: 8.4)

Equals sign not aligned with surrounding assignments; expected 11 spaces but found 12 spaces
$options['length'] = $mapping->length ?? null;

Check failure on line 458 in src/Tools/SchemaTool.php

View workflow job for this annotation

GitHub Actions / coding-standards / Coding Standards (PHP: 8.4)

Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces

$options['notnull'] = isset($mapping->nullable) ? ! $mapping->nullable : true;
if ($class->isInheritanceTypeSingleTable() && $class->parentClasses) {
$options['notnull'] = false;
Expand All @@ -465,7 +466,7 @@
$options['platformOptions']['version'] = $class->isVersioned && $class->versionField === $mapping->fieldName;

if (strtolower($columnType) === 'string' && $options['length'] === null) {
$options['length'] = 255;
$options['length'] = $this->em->getConfiguration()->getDefaultStringTypeSchemaLength();
}

if (isset($mapping->precision)) {
Expand Down
Loading