Skip to content

Commit 787c8fa

Browse files
authored
Fix schema specification support in WHERE clauses (#322)
* Fix bug with WHERE from other db * Change name * Change name back
1 parent 1a0e9ad commit 787c8fa

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/Queries/Common.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ private function createUndefinedJoins($statement)
359359
// don't rewrite table from other databases
360360
foreach ($this->joins as $join) {
361361
if (strpos($join, '.') !== false && strpos($statement, $join) === 0) {
362+
// rebuild the where statement
363+
if ($separator !== null) {
364+
$statement = [$separator, $statement];
365+
}
366+
362367
return $statement;
363368
}
364369
}

tests/Queries/CommonTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public function testClauseWithRefBeforeJoin()
206206

207207
public function testFromOtherDB()
208208
{
209-
$queryPrint = $this->fluent->from('db2.user')->order('db2.user.name')->getQuery(false);
209+
$queryPrint = $this->fluent->from('db2.user')->where('db2.user.name', 'name')->order('db2.user.name')->getQuery(false);
210210

211-
self::assertEquals('SELECT db2.user.* FROM db2.user ORDER BY db2.user.name', $queryPrint);
211+
self::assertEquals('SELECT db2.user.* FROM db2.user WHERE db2.user.name = ? ORDER BY db2.user.name', $queryPrint);
212212
}
213213

214214
public function testJoinTableWithUsing()

0 commit comments

Comments
 (0)