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
5 changes: 5 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ and directly start using native lazy objects.

# Upgrade to 3.6

## Deprecate `FieldMapping::$default`

The `default` property of `Doctrine\ORM\Mapping\FieldMapping` is deprecated and
will be removed in 4.0. Instead, use `FieldMapping::$options['default']`.

## Deprecate specifying `nullable` on columns that end up being used in a primary key

Specifying `nullable` on join columns that are part of a primary key is
Expand Down
4 changes: 2 additions & 2 deletions src/Mapping/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -2480,9 +2480,9 @@ public function setVersionMapping(array &$mapping): void

if (! isset($mapping['default'])) {
if (in_array($mapping['type'], ['integer', 'bigint', 'smallint'], true)) {
$mapping['default'] = 1;
$mapping['options']['default'] = 1;
} elseif ($mapping['type'] === 'datetime') {
$mapping['default'] = 'CURRENT_TIMESTAMP';
$mapping['options']['default'] = 'CURRENT_TIMESTAMP';
} else {
throw MappingException::unsupportedOptimisticLockingType($this->name, $mapping['fieldName'], $mapping['type']);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Mapping/FieldMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ final class FieldMapping implements ArrayAccess
public string|null $declaredField = null;
public array|null $options = null;
public bool|null $version = null;
public string|int|null $default = null;

/** @deprecated Use options with 'default' key instead */
public string|int|null $default = null;

/**
* @param string $type The type name of the mapped field. Can be one of
Expand Down
2 changes: 2 additions & 0 deletions src/Tools/SchemaTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ private function gatherColumn(
$options['scale'] = $mapping->scale;
}

/** @phpstan-ignore property.deprecated */
if (isset($mapping->default)) {
/** @phpstan-ignore property.deprecated */
$options['default'] = $mapping->default;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/ORM/Mapping/ClassMetadataBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function testCreateVersionedField(): void
FieldMapping::fromMappingArray([
'columnDefinition' => 'foobar',
'columnName' => 'username',
'default' => 1,
'options' => ['default' => 1],
'fieldName' => 'name',
'length' => 124,
'type' => 'integer',
Expand Down