mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-20 09:09:33 +00:00
Allow to find existing parts via the stored providerReference
This should allow the database to more quickly find entries
This commit is contained in:
parent
77ecd99646
commit
38a8c6bacc
1 changed files with 16 additions and 6 deletions
|
|
@ -41,12 +41,22 @@ final class ExistingPartFinder
|
|||
$qb = $this->em->getRepository(Part::class)->createQueryBuilder('part');
|
||||
$qb->select('part')
|
||||
->leftJoin('part.manufacturer', 'manufacturer')
|
||||
//The manufacturer name must match
|
||||
->where("ILIKE(manufacturer.name, :manufacturerName) = TRUE")
|
||||
//And the manufacturer product number must match
|
||||
->andWhere(
|
||||
"ILIKE(part.manufacturer_product_number, :mpn) = TRUE"
|
||||
);
|
||||
->Orwhere($qb->expr()->andX(
|
||||
'part.providerReference.provider_key = :providerKey',
|
||||
'part.providerReference.provider_id = :providerId',
|
||||
))
|
||||
|
||||
//Or the manufacturer and the MPN must match
|
||||
->OrWhere(
|
||||
$qb->expr()->andX(
|
||||
"ILIKE(manufacturer.name, :manufacturerName) = TRUE",
|
||||
"ILIKE(part.manufacturer_product_number, :mpn) = TRUE"
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
$qb->setParameter('providerKey', $dto->provider_key);
|
||||
$qb->setParameter('providerId', $dto->provider_id);
|
||||
|
||||
$qb->setParameter('manufacturerName', $dto->manufacturer);
|
||||
$qb->setParameter('mpn', $dto->mpn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue