cycle / database

Database Abstraction Layer, Schema Introspection, Schema Generation, Query Builders
MIT License
53 stars 22 forks source link

🐛 Interpolation ignores 'withDatetimeMicroseconds' driver option #154

Closed moroswitie closed 6 months ago

moroswitie commented 6 months ago

No duplicates 🥲.

Database

SQLite, MySQL, PostgreSQL, MSSQL

What happened?

While testing a time sensitive application I discovered that the Interpolator::class does not take into consideration the withDatetimeMicroseconds driver option for datetime types.

\\  Interpolator::class
        switch (\gettype($parameter)) {
            // ... 
            case 'object':
                if ($parameter instanceof Stringable) {
                    return "'" . self::escapeStringValue((string)$parameter, "'") . "'";
                }

                if ($parameter instanceof DateTimeInterface) {
                    return "'" . $parameter->format(DateTimeInterface::ATOM) . "'";
                }
        }

Instead it uses a hardcoded value of: DateTimeInterface::ATOM. It is a minor bug which you will only encounter if you are debugging (with a logger) and are using microsecond precision.

Version

database 2.7.1
PHP 8.3