Skip to content

Commit 87b5fce

Browse files
author
David Nahodyl
committed
added == for key searches to get exact matches and handle things like email addresses as keys
1 parent 59f82d8 commit 87b5fce

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

src/Database/Eloquent/FMEloquentBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ public function whereKeyNot($id)
118118

119119
// If this is our first where clause we can add the omit directly
120120
if (sizeof($this->wheres) === 0){
121-
return $this->where($this->model->getKeyName(), $id)->omit();
121+
return $this->where($this->model->getKeyName(), '==', $id)->omit();
122122
}
123123

124124
// otherwise we need to add a find and omit
125-
return $this->orWhere($this->model->getKeyName(), $id)->omit();
125+
return $this->orWhere($this->model->getKeyName(), '==', $id)->omit();
126126
}
127127

128128

src/Database/Eloquent/Relations/BelongsTo.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ public function addConstraints()
1717
// For belongs to relationships, which are essentially the inverse of has one
1818
// or has many relationships, we need to actually query on the primary key
1919
// of the related models matching on the foreign key that's on a parent.
20-
$table = $this->related->getTable();
21-
22-
$this->query->where($this->ownerKey, '=', $this->child->{$this->foreignKey});
20+
$this->query->where($this->ownerKey, '==', $this->child->{$this->foreignKey});
2321
}
2422
}
2523
}

src/Database/Eloquent/Relations/HasMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class HasMany extends \Illuminate\Database\Eloquent\Relations\HasMany
1515
public function addConstraints()
1616
{
1717
if (static::$constraints) {
18-
$this->query->where($this->foreignKey, '=', $this->getParentKey());
18+
$this->query->where($this->foreignKey, '==', $this->getParentKey());
1919
}
2020
}
2121

src/Database/Eloquent/Relations/HasOne.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class HasOne extends \Illuminate\Database\Eloquent\Relations\HasOne
1414
public function addConstraints()
1515
{
1616
if (static::$constraints) {
17-
$this->query->where($this->foreignKey, '=', $this->getParentKey());
17+
$this->query->where($this->foreignKey, '==', $this->getParentKey());
1818
}
1919
}
2020
}

0 commit comments

Comments
 (0)