Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f2b9d7c

Browse files
[6.x] Port whereKey fix and bugfix for null type (#34031)
* [7.x] Cast primary key to string when $keyType is string (#33930) * Cast primary key to string when $keyType is string * fix test * fix remaining tests * Fix bug with whereKey null Co-authored-by: Steve Thomas <[email protected]>
1 parent 0c54827 commit f2b9d7c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Eloquent/Builder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ public function whereKey($id)
193193
return $this;
194194
}
195195

196+
if ($id !== null && $this->model->getKeyType() === 'string') {
197+
$id = (string) $id;
198+
}
199+
196200
return $this->where($this->model->getQualifiedKeyName(), '=', $id);
197201
}
198202

@@ -210,6 +214,10 @@ public function whereKeyNot($id)
210214
return $this;
211215
}
212216

217+
if ($id !== null && $this->model->getKeyType() === 'string') {
218+
$id = (string) $id;
219+
}
220+
213221
return $this->where($this->model->getQualifiedKeyName(), '!=', $id);
214222
}
215223

0 commit comments

Comments
 (0)