mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
DibiFluent: fixed combination of modifier and inner fluent [Closes #192]
This commit is contained in:
@@ -175,7 +175,10 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
} elseif (is_string($arg) && preg_match('#^[a-z:_][a-z0-9_.:]*\z#i', $arg)) { // identifier
|
||||
$args = array('%n', $arg);
|
||||
|
||||
} elseif (is_array($arg) || ($arg instanceof Traversable && !$arg instanceof self)) { // any array
|
||||
} elseif ($arg instanceof self) {
|
||||
$args = array('%SQL', $arg);
|
||||
|
||||
} elseif (is_array($arg) || $arg instanceof Traversable) { // any array
|
||||
if (isset(self::$modifiers[$clause])) {
|
||||
$args = array(self::$modifiers[$clause], $arg);
|
||||
|
||||
@@ -187,7 +190,6 @@ class DibiFluent extends DibiObject implements IDataSource
|
||||
|
||||
foreach ($args as $arg) {
|
||||
if ($arg instanceof self) {
|
||||
$this->cursor[] = '%SQL';
|
||||
$arg = "($arg)";
|
||||
}
|
||||
$this->cursor[] = $arg;
|
||||
|
@@ -141,3 +141,12 @@ Assert::same(
|
||||
reformat('SELECT * FROM [me] AS [t] WHERE col > 10 AND ([x] = \'a\') AND (b) AND (c)'),
|
||||
(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
|
||||
);
|
||||
|
Reference in New Issue
Block a user