-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DoctrineBridge] Add new DatePointDateType
Doctrine type
#60237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 7.3
Are you sure you want to change the base?
Conversation
I removed the direct mentions to avoid notification spam when the PR is merged |
How is it "problematic"? |
@garak For example, Doctrine Migrations for PostgreSQL will generate migrations using the TIMESTAMP type instead of DATE. The schema will never be fully synchronized if you try to force it. Relational databases have dedicated data types for storing DATE and DATETIME, which is why PHP's DateTime is represented by two separate types in Doctrine. |
First of all, thank you for bringing up this topic. Secondly: Naming things is hard.
My proposal: Keep the |
$format = 'Y-m-d H:i:s.u'; | ||
$date = '2025-03-03'; | ||
$actual = $this->type->convertToPHPValue($date, self::getSqlitePlatform()); | ||
$expected = DatePoint::createFromFormat('!Y-m-d', $date); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about the !
:
Resets all fields (year, month, day, hour, minute, second, fraction and timezone information) to zero-like values ( 0 for hour, minute, second and fraction, 1 for month and day, 1970 for year and UTC for timezone information)
Without!
, all fields will be set to the current date and time.
@derrabus Ok, so we're leaning more towards Symfony's naming conventions rather than Doctrine's. You contribute a lot to Doctrine, so this is an important note. |
@derrabus After the changes you suggested, this is how it will look. doctrine:
dbal:
types:
date_point: Symfony\Bridge\Doctrine\Types\DatePointType
date_point_date: Symfony\Bridge\Doctrine\Types\DatePointDateType #[ORM\Column(type: 'date_point_date')]
public DatePoint $birthday;
#[ORM\Column(type: 'date_point')]
public DatePoint $createdAt; |
acb035e
to
7d6da09
Compare
7d6da09
to
31ca901
Compare
DatePointDateType
Doctrine type
31ca901
to
e5ec79a
Compare
e5ec79a
to
9f41419
Compare
Added missing test |
Doctri 8000 ne provides both date_immutable and datetime_immutable types. Restricting the conversion of DatePoint only to datetime_immutable is problematic.
Therefore, I propose renaming the current DatePointType to DateTimePointType, and introducing a new DatePointType.
Previous pull request.
If this pull request is to be merged, it should be included in version 7.3 to avoid any breaking changes in the future.