Skip to content

Commit

Permalink
updated addIdentifiersToQuery to work with custom types.
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-andreyev committed Feb 2, 2020
1 parent ffa2275 commit 28fd117
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Model/ModelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ public function addIdentifiersToQuery($class, ProxyQueryInterface $queryProxy, a
{
$fieldNames = $this->getIdentifierFieldNames($class);
$qb = $queryProxy->getQueryBuilder();
$classMetadata = $this->getMetadata($class);

$prefix = uniqid();
$sqls = [];
Expand All @@ -414,7 +415,14 @@ public function addIdentifiersToQuery($class, ProxyQueryInterface $queryProxy, a
foreach ($fieldNames as $posName => $name) {
$parameterName = sprintf('field_%s_%s_%d', $prefix, $name, $pos);
$ands[] = sprintf('%s.%s = :%s', current($qb->getRootAliases()), $name, $parameterName);
$qb->setParameter($parameterName, $ids[$posName]);

$fieldMapping = $classMetadata->getFieldMapping($name);
$type = null;
if (Type::hasType($fieldMapping['type'])) {
$type = Type::getType($fieldMapping['type']);
}

$qb->setParameter($parameterName, $ids[$posName], $type ? $type->getName() : null);
}

$sqls[] = implode(' AND ', $ands);
Expand Down

0 comments on commit 28fd117

Please sign in to comment.