diff --git a/src/Dibi/Fluent.php b/src/Dibi/Fluent.php index 46cec1e0..2f8d6775 100644 --- a/src/Dibi/Fluent.php +++ b/src/Dibi/Fluent.php @@ -189,8 +189,7 @@ class Fluent implements IDataSource foreach ($args as $arg) { if ($arg instanceof self) { - $this->cursor[] = '%SQL'; - $arg = "($arg)"; + $arg = new Literal("($arg)"); } $this->cursor[] = $arg; } diff --git a/tests/dibi/Fluent.select.phpt b/tests/dibi/Fluent.select.phpt index 119c17df..9f512ef3 100644 --- a/tests/dibi/Fluent.select.phpt +++ b/tests/dibi/Fluent.select.phpt @@ -151,3 +151,12 @@ Assert::same( reformat(' SELECT * LIMIT 1 OFFSET 1'), (string) $fluent ); + + +$fluent = $conn->select('*')->from('abc') + ->where('x IN (%SQL)', $conn->select('id')->from('xyz')); + +Assert::same( + reformat('SELECT * FROM [abc] WHERE x IN ((SELECT [id] FROM [xyz]))'), + (string) $fluent +);