Skip to content

Commit 42e278e

Browse files
committed
Deprecate magic default values
1 parent 2d9b8e2 commit 42e278e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

UPGRADE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ awareness about deprecated code.
88

99
# Upgrade to 4.4
1010

11+
## Deprecated using current date, time and timestamp SQL expressions as default values
12+
13+
Using SQL expressions for the current date, time, or timestamp as column default values is deprecated. Instead, use an
14+
instance of the `CurrentDate`, `CurrentTime`, or `CurrentTimestamp` class, respectively.
15+
1116
## Deprecated `Schema::createNamespace()` and the `$namespaces` constructor parameter
1217

1318
The `Schema::createNamespace()` method and the `$namespaces` constructor parameter have been deprecated. The schema

src/Platforms/AbstractPlatform.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,14 +1559,35 @@ public function getDefaultValueDeclarationSQL(array $column): string
15591559
}
15601560

15611561
if ($type instanceof Types\PhpDateTimeMappingType && $default === $this->getCurrentTimestampSQL()) {
1562+
Deprecation::trigger(
1563+
'doctrine/dbal',
1564+
'https://github.com/doctrine/dbal/pull/7195',
1565+
'Using "%s" as a column default value is deprecated. Use a CurrentTimestamp instance instead.',
1566+
$default,
1567+
);
1568+
15621569
return ' DEFAULT ' . $this->getCurrentTimestampSQL();
15631570
}
15641571

15651572
if ($type instanceof Types\PhpTimeMappingType && $default === $this->getCurrentTimeSQL()) {
1573+
Deprecation::trigger(
1574+
'doctrine/dbal',
1575+
'https://github.com/doctrine/dbal/pull/7195',
1576+
'Using "%s" as a column default value is deprecated. Use a CurrentTime instance instead.',
1577+
$default,
1578+
);
1579+
15661580
return ' DEFAULT ' . $this->getCurrentTimeSQL();
15671581
}
15681582

15691583
if ($type instanceof Types\PhpDateMappingType && $default === $this->getCurrentDateSQL()) {
1584+
Deprecation::trigger(
1585+
'doctrine/dbal',
1586+
'https://github.com/doctrine/dbal/pull/7195',
1587+
'Using "%s" as a column default value is deprecated. Use a CurrentDate instance instead.',
1588+
$default,
1589+
);
1590+
15701591
return ' DEFAULT ' . $this->getCurrentDateSQL();
15711592
}
15721593

0 commit comments

Comments
 (0)