1
0
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:
David Grudl
2015-11-02 14:48:22 +01:00
parent 84f3a5ddef
commit 411862d5d8
2 changed files with 13 additions and 2 deletions

View File

@@ -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;

View File

@@ -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
);