Skip to content
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

feat: add TIMESTAMP and TIME precision #6438

Closed
wants to merge 1 commit into from

Conversation

vencakrecl
Copy link

@vencakrecl vencakrecl commented Jun 13, 2024

Q A
Type feature
Fixed issues

Summary

Added support for precision for PostgreSQL TIMESTAMP and TIME. It would be nice to have this feature per column but it is impossible with the current implementation of datetime types.

How to use:

<?php

declare(strict_types=1);

namespace App\Doctrine;

use Doctrine\Bundle\DoctrineBundle\Attribute\AsMiddleware;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Middleware;
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;

#[AsMiddleware]
class QueuesMiddleware implements Middleware
{
    public function wrap(Driver $driver): Driver
    {
        return new class extends AbstractDriverMiddleware {
            public function getDatabasePlatform(): PostgreSqlPlatform
            {
                $platform = new PostgreSqlPlatform();
                $platform->setTimestampPrecision(6);

                return $platform;
            }

            public function createDatabasePlatformForVersion($version): PostgreSqlPlatform
            {
                return $this->getDatabasePlatform();
            }
        };
    }
}

@vencakrecl vencakrecl force-pushed the datetime-precision branch from 36992cd to e6c47ee Compare June 13, 2024 19:59
@vencakrecl vencakrecl changed the title feat: add time and datetime precision feat: add TIMESTAMP and TIME precision Jun 13, 2024
@vencakrecl vencakrecl force-pushed the datetime-precision branch 8 times, most recently from 5225c02 to 95a3de0 Compare June 14, 2024 05:30
@vencakrecl vencakrecl force-pushed the datetime-precision branch from 95a3de0 to 9a889f7 Compare July 7, 2024 21:10
@vencakrecl vencakrecl changed the base branch from 3.8.x to 4.1.x July 7, 2024 21:11
Copy link
Member

@derrabus derrabus left a comment

Choose a reason for hiding this comment

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

Thank you. This feature has been attempted before. Please have a look at prior art in #5961 and #6393.

My main issues with your PR so far:

  • It's Postgres-only although other DBMS support this feature in some shape or form as well.
  • Zero functional tests. We need tests that include actual databases or we'll never know if your feature works.

@derrabus derrabus changed the base branch from 4.1.x to 4.2.x August 15, 2024 09:18
@derrabus
Copy link
Member

Closing due to lack of feedback.

@derrabus derrabus closed this Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants