Skip to content

Commit

Permalink
Cache : handle edge case when entity key is a MongoDB ObjectId
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiCollin committed Mar 15, 2018
1 parent 3c19f07 commit e02226c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/System/Aggregate.php
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Support\Collection;
use ProxyManager\Proxy\LazyLoadingInterface;
use ProxyManager\Proxy\ProxyInterface;
use MongoDB\BSON\ObjectId;

/**
* This class is aimed to facilitate the handling of
Expand Down Expand Up @@ -375,7 +376,13 @@ public function getEntityKeyName(): string
*/
public function getEntityKeyValue()
{
return $this->wrappedEntity->getEntityKeyValue();
$keyValue = $this->wrappedEntity->getEntityKeyValue();

if($keyValue instanceof ObjectId) {
$keyValue = (string) $keyValue;
}

return $keyValue;
}

/**
Expand Down

0 comments on commit e02226c

Please sign in to comment.