This commit is contained in:
thinkphp
2018-02-14 12:14:06 +08:00
parent 09402cee9b
commit 9606f235f2
2 changed files with 4 additions and 2 deletions

View File

@@ -173,7 +173,8 @@ class HasOne extends OneToOne
{
$localKey = $this->localKey;
$foreignKey = $this->foreignKey;
$data = $this->eagerlyWhere($this, [$foreignKey => $result->$localKey], $foreignKey, $relation, $subRelation, $closure);
$this->query->removeWhereField($foreignKey);
$data = $this->eagerlyWhere($this->query, [$foreignKey => $result->$localKey], $foreignKey, $relation, $subRelation, $closure);
// 关联模型
if (!isset($data[$result->$localKey])) {