1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 13:17:58 +02:00

Translator: DateTime can be used only with %d or %t modifiers (BC break?)

This commit is contained in:
David Grudl
2015-11-02 16:57:02 +01:00
parent b7d922d992
commit 0c22f3b43f
2 changed files with 6 additions and 1 deletions

View File

@@ -333,7 +333,7 @@ final class Translator
if ($value !== NULL && !is_scalar($value)) { // array is already processed
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
$modifier = 'SQL';
} elseif ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
} elseif (($value instanceof \DateTime || $value instanceof \DateTimeInterface) && ($modifier === 'd' || $modifier === 't')) {
// continue
} else {
$type = is_object($value) ? get_class($value) : gettype($value);

View File

@@ -190,6 +190,11 @@ Assert::same(
'b9%t' => NULL,
]));
Assert::exception(function () use ($conn) {
$conn->translate('SELECT %s', new DateTime('1212-09-26'));
}, 'Dibi\Exception', 'SQL translate error: Invalid combination of type Dibi\DateTime and modifier %s');
// like