TODO Add "relation.field" where clause support

@param QueryBuilder $builder
@param CriterionInterface|Where $where
@return iterable|null
324161
public function apply($builder, CriterionInterface $where): ?iterable
    {
        $expression = new Expression($builder, $where->getOperator(), $where->getValue());
        yield from $result = $expression->create($where->getField());

        if ($where->isAnd()) {
            $builder->andWhere($result->getReturn());
        } else {
            $builder->orWhere($result->getReturn());
        }
    }
856680
protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = null)
    {
        if (null === $criteria) {
            return;
        }

        foreach ($criteria as $property => $value) {
            if (null === $value) {
                $queryBuilder
                    ->andWhere($queryBuilder->expr()->isNull($this->getPropertyName($property)));
            } elseif (!is_array($value)) {
                $queryBuilder
                    ->andWhere($queryBuilder->expr()->eq($this->getPropertyName($property), ':' . $property))
                    ->setParameter($property, $value);
            } else {
                $queryBuilder->andWhere($queryBuilder->expr()->in($this->getPropertyName($property), $value));
            }
        }
    }
66708
public function apply(QueryBuilder $builder)
    {
        $builder->where($this->name, $this->operation, $this->value);
    }
662301
public function createQueryBuilderForMetadataAndEnabledsSelection(Metadata $metadata, array $criteria = null, array $orderBy = null, $limit = null, $offset = null, $class = null)
    {
        $qb = $this->createQueryBuilder($criteria, $orderBy, $limit, $offset, $class); // TODO: Change the autogenerated stub

        $qb->leftJoin($qb->getRootAliases()[0] . '.metadata', 'm');
        $qb->leftJoin($qb->getRootAliases()[0] . '.table', 't');
        $qb->andWhere($qb->expr()->eq('m.id', '\'' . $metadata->getId() . '\''));
        $qb->andWhere($qb->expr()->eq($qb->getRootAliases()[0] . '.enabled', true));
        $qb->addOrderBy('t.position', 'ASC');
        $qb->addOrderBy($qb->getRootAliases()[0] . '.title', 'ASC');

        return $qb;
    }
353572
public function setConditionBuilder(\pwf\components\querybuilder\interfaces\ConditionBuilder $builder)
    {
        $this->conditionBuilder = $builder;
        return $this;
    }
89149
protected function applyWhere(Builder $query, array $where)
    {
        foreach ($where as $key => $value) {
            if (is_null($value)) {
                $query = $query->whereNull($key);
            } else {
                if (is_array($value)) {
                    $query = $query->where($key, $value[0], $value[1]);
                } else {
                    $query = $query->where($key, '=', $value);
                }
            }
        }

        return $query;
    }
109413
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\LocationId &&
            (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ
            );
    }
1207646
protected function where($where)
    {
        foreach($where as $field => $value) {
            $this->queryBuilder->where($field, $value);
        }
    }
690466
public function where($column, $value = '', $operator = Criterion::EQUALS, $variable = null, $additional = null, $special = null): self
        {
            if (!$column instanceof CriterionProvider) {
                $column = new Criterion($column, $value, $operator, $variable, $additional, $special);
            }

            $this->parts[] = $column;

            return $this;
        }
701291
public function createQueryBuilder(array $criteria = null, array $orderBy = null, $limit = null, $offset = null, $class = null)
    {
        $baseQueryBuilder = $this->createBaseQueryBuilder($class);

        $queryBuilder = $this->alterBaseQueryBuilder($baseQueryBuilder);

        if (!is_null($criteria)) {
            foreach ($criteria as $key => $value) {
                $queryBuilder->andWhere($queryBuilder->getRootAliases()[0] . '.' . $key . ' = ' . $this->addNamedParameter($key, $value, $queryBuilder));
            }
        }

        if (!is_null($orderBy)) {
            foreach ($orderBy as $sort => $order) {
                $queryBuilder->addOrderBy($queryBuilder->getRootAliases()[0] . '.' . $sort, $order);
            }
        }

        if (!is_null($limit)) {
            $queryBuilder->setMaxResults($limit);
        }

        if (!is_null($offset)) {
            $queryBuilder->setFirstResult($offset);
        }

        return $queryBuilder;
    }
460635
private function getQueryTypeFilterCriteria(ParameterCollectionInterface $parameterCollection, Location $parentLocation): ?Criterion
    {
        if ($parameterCollection->getParameter('query_type')->getValue() !== 'list') {
            return null;
        }

        return new Criterion\Location\Depth(
            Criterion\Operator::EQ,
            $parentLocation->depth + 1
        );
    }
602676
protected function getQueryCondition(
        Criterion $filter,
        SelectQuery $query,
        array $languageFilter
    ) {
        $condition = $query->expr->lAnd(
            $this->criteriaConverter->convertCriteria($query, $filter, $languageFilter),
            $query->expr->eq(
                'ezcontentobject.status',
                ContentInfo::STATUS_PUBLISHED
            ),
            $query->expr->eq(
                'ezcontentobject_version.status',
                VersionInfo::STATUS_PUBLISHED
            )
        );

        // If not main-languages query
        if (!empty($languageFilter['languages'])) {
            $condition = $query->expr->lAnd(
                $condition,
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->handler->quoteColumn('language_mask', 'ezcontentobject'),
                        $query->bindValue(
                            $this->getLanguageMask($languageFilter),
                            null,
                            PDO::PARAM_INT
                        )
                    ),
                    $query->bindValue(0, null, PDO::PARAM_INT)
                )
            );
        }

        return $condition;
    }
1012133
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\DateMetadata &&
            $criterion->target === 'modified' &&
            (
                $criterion->operator === Operator::LT ||
                $criterion->operator === Operator::LTE ||
                $criterion->operator === Operator::GT ||
                $criterion->operator === Operator::GTE ||
                $criterion->operator === Operator::BETWEEN
            );
    }
617691
protected function dateBasedWhere($type, Builder $query, $where)
    {
        $value = $this->parameter($where['value']);

        return 'extract('.$type.' from '.$this->wrap($where['column']).') '.$where['operator'].' '.$value;
    }
464869
protected function parseConditions(QueryBuilderInterface $queryBuilder, $where)
    {
        if (empty($where)) {
            return '';
        }

        $sql = '';
        if ($this->isWherePart($where)) {
            $operator = $where['___operator'];
            $childWhere = $where['___where'];
            $condition = $where['___condition'];
            if ($this->isWherePart($childWhere)) {
                $whereSql = $this->parseConditions($queryBuilder, $childWhere);
                $sql .= '('.$whereSql.') '.strtoupper($operator).' ('.$this->parsePart($condition, $operator).')';
            } else {
                $sql .= $this->parsePart($queryBuilder, $childWhere, $operator);
            }
        } else {
            $sql .= $this->parsePart($queryBuilder, $where);
        }

        if (empty($sql)) {
            return '';
        }

        return $sql;
    }
53053
protected function whereBasic(Builder $query, $where)
    {
        if (Str::contains(strtolower($where['operator']), 'like')) {
            return sprintf(
                '%s::text %s %s',
                $this->wrap($where['column']),
                $where['operator'],
                $this->parameter($where['value'])
            );
        }

        return parent::whereBasic($query, $where);
    }
660264
public function mapLoadCriteriaToQuery(ILoadCriteria $criteria) : MappedLoadQuery
    {
        $select = $this->criteriaMapper->mapCriteriaToSelect($criteria, $memberMappings, $criteria->getAliasNestedMemberMap());
        $select->setColumns([]);

        $columnIndexMap  = [];
        $relationsToLoad = [];

        foreach ($criteria->getAliasNestedMemberMap() as $alias => $member) {
            /** @var MemberMappingWithTableAliases $memberMapping */
            $memberMapping = $memberMappings[$member->asString()];
            $mapping       = $memberMapping->getMapping();

            if ($mapping instanceof IFinalRelationMemberMapping) {
                $memberRelation   = $mapping->asMemberRelation();
                $parentTableAlias = $memberRelation instanceof ToManyMemberRelation || !($memberRelation->getFirstRelation() instanceof ISeparateTableRelation) || count($memberMapping->getTableAliases()) === 1
                    ? $memberMapping->getLastTableAlias()
                    : $memberMapping->getSecondLastTableAlias();
                $parentTable      = $select->getTableFromAlias($parentTableAlias);
                $parentColumnMap  = [];

                $parentColumnsToLoad = $memberRelation->getParentColumnsToLoad();

                if (!($mapping instanceof ToOneEmbeddedObjectMapping)) {
                    $parentColumnsToLoad[] = $parentTable->getPrimaryKeyColumnName();
                }

                foreach ($parentColumnsToLoad as $column) {
                    $parentColumnMap[$alias . '_' . $column] = $column;

                    $select->addColumn($alias . '_' . $column, Expr::column($parentTableAlias, $parentTable->getColumn($column)));
                }

                $relationsToLoad[$alias] = [$memberRelation, $parentTable, $parentColumnMap];
            } else {
                $mapping->addSelectColumn($select, $memberMapping->getLastTableAlias(), $alias);
                $columnIndexMap[$alias] = $alias;
            }
        }

        foreach ($memberMappings as $key => $memberMapping) {
            /** @var MemberMappingWithTableAliases $memberMapping */
            $memberMappings[$key] = $memberMapping->getMapping();
        }


        return new MappedLoadQuery($select, $columnIndexMap, $relationsToLoad);
    }