mirror of
https://github.com/dg/dibi.git
synced 2025-08-04 21:28:02 +02:00
Translator: DateTime can be used only with %d or %t modifiers (BC break?)
This commit is contained in:
@@ -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);
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user