mirror of
https://github.com/dg/dibi.git
synced 2025-08-01 11:50:15 +02:00
Translator: improved Expression usage
This commit is contained in:
@@ -316,7 +316,11 @@ final class Translator
|
||||
if ($modifier) {
|
||||
if ($value !== null && !is_scalar($value)) { // array is already processed
|
||||
if ($value instanceof Literal && ($modifier === 'sql' || $modifier === 'SQL')) {
|
||||
$modifier = 'SQL';
|
||||
return (string) $value;
|
||||
|
||||
} elseif ($value instanceof Expression && $modifier === 'ex') {
|
||||
return $this->connection->translate(...$value->getValues());
|
||||
|
||||
} elseif ($value instanceof \DateTimeInterface && ($modifier === 'd' || $modifier === 't' || $modifier === 'dt')) {
|
||||
// continue
|
||||
} else {
|
||||
|
@@ -507,6 +507,18 @@ Assert::same(
|
||||
);
|
||||
|
||||
|
||||
Assert::same(
|
||||
reformat('SELECT * FROM [table] WHERE (([left] = 1) OR ([top] = 2)) AND (number < 100)'),
|
||||
$conn->translate('SELECT * FROM `table` WHERE %and', [
|
||||
new Dibi\Expression('%or', [
|
||||
'left' => 1,
|
||||
'top' => 2,
|
||||
]),
|
||||
new Dibi\Expression('number < %i', 100),
|
||||
])
|
||||
);
|
||||
|
||||
|
||||
$e = Assert::exception(function () use ($conn) {
|
||||
$array6 = [
|
||||
'id' => [1, 2, 3, 4],
|
||||
|
Reference in New Issue
Block a user