Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unique alias to custom objects query #321

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Segment/Query/Filter/CustomFieldFilterQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace MauticPlugin\CustomObjectsBundle\Segment\Query\Filter;

use Doctrine\DBAL\DBALException;
use Mautic\LeadBundle\Segment\ContactSegmentFilter;
use Mautic\LeadBundle\Segment\Query\Filter\BaseFilterQueryBuilder;
use Mautic\LeadBundle\Segment\Query\QueryBuilder as SegmentQueryBuilder;
Expand Down Expand Up @@ -35,15 +34,13 @@ public static function getServiceId()
return 'mautic.lead.query.builder.custom_field.value';
}

/**
* @throws DBALException
*/
/** {@inheritDoc} */
public function applyQuery(SegmentQueryBuilder $queryBuilder, ContactSegmentFilter $filter): SegmentQueryBuilder
{
$leadsTableAlias = $queryBuilder->getTableAlias(MAUTIC_TABLE_PREFIX.'leads');
$filterOperator = $filter->getOperator();

$tableAlias = 'cfwq_'.(int) $filter->getField();
$tableAlias = sprintf('cfwq_%d_%s', (int) $filter->getField(), uniqid());

$unionQueryContainer = $this->filterHelper->createValueQuery(
$tableAlias,
Expand Down