diff --git a/src/Dibi/Translator.php b/src/Dibi/Translator.php index df0212a2..e5ea23f8 100644 --- a/src/Dibi/Translator.php +++ b/src/Dibi/Translator.php @@ -330,9 +330,15 @@ final class Translator // with modifier procession if ($modifier) { - if ($value !== NULL && !is_scalar($value) && !$value instanceof \DateTime && !$value instanceof \DateTimeInterface) { // array is already processed - $type = is_object($value) ? get_class($value) : gettype($value); - return $this->errors[] = "**Invalid combination of type $type and modifier %$modifier**"; + 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) { + // continue + } else { + $type = is_object($value) ? get_class($value) : gettype($value); + return $this->errors[] = "**Invalid combination of type $type and modifier %$modifier**"; + } } switch ($modifier) { diff --git a/tests/dibi/Translator.phpt b/tests/dibi/Translator.phpt index f507f696..97c98ff4 100644 --- a/tests/dibi/Translator.phpt +++ b/tests/dibi/Translator.phpt @@ -519,6 +519,10 @@ Assert::same( $conn->translate('SELECT', new Dibi\Literal('* FROM table')) ); +Assert::same( + reformat('SELECT * FROM table'), + $conn->translate('SELECT %SQL', new Dibi\Literal('* FROM table')) +); Assert::same( reformat('SELECT * FROM table'),