mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-22 01:59:34 +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 = $this->em->getRepository(Part::class)->createQueryBuilder('part');
|
||||||
$qb->select('part')
|
$qb->select('part')
|
||||||
->leftJoin('part.manufacturer', 'manufacturer')
|
->leftJoin('part.manufacturer', 'manufacturer')
|
||||||
//The manufacturer name must match
|
->Orwhere($qb->expr()->andX(
|
||||||
->where("ILIKE(manufacturer.name, :manufacturerName) = TRUE")
|
'part.providerReference.provider_key = :providerKey',
|
||||||
//And the manufacturer product number must match
|
'part.providerReference.provider_id = :providerId',
|
||||||
->andWhere(
|
))
|
||||||
"ILIKE(part.manufacturer_product_number, :mpn) = TRUE"
|
|
||||||
);
|
//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('manufacturerName', $dto->manufacturer);
|
||||||
$qb->setParameter('mpn', $dto->mpn);
|
$qb->setParameter('mpn', $dto->mpn);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue