Add match clause to match all parts of the aggregate that needs to be updated

@param MapInterface<string, mixed> $changeset
777642
private function matchAggregate(
        Identity $identity,
        object $entity,
        Aggregate $meta,
        MapInterface $changeset,
        Query $query
    ): Query {
        $name = $this->name->sprintf(\md5($identity->value()));
        $query = $query
            ->match(
                (string) $name,
                $meta->labels()->toPrimitive()
            )
            ->withProperty(
                $meta->identity()->property(),
                (string) $name
                    ->prepend('{')
                    ->append('_identity}')
            )
            ->withParameter(
                (string) $name->append('_identity'),
                $identity->value()
            );
        $this->variables = $this->variables->put(
            $name,
            $this->buildProperties(
                $changeset,
                $meta->properties()
            )
        );

        return $meta
            ->children()
            ->filter(static function(string $property) use ($changeset): bool {
                return $changeset->contains($property);
            })
            ->reduce(
                $query,
                function(Query $carry, string $property, Child $child) use ($changeset, $name): Query {
                    $changeset = $changeset->get($property);
                    $childName = null;
                    $relName = $name
                        ->append('_')
                        ->append($property);
                    $this->variables = $this->variables->put(
                        $relName,
                        $this->buildProperties(
                            $changeset,
                            $child->relationship()->properties()
                        )
                    );

                    if ($changeset->contains($child->relationship()->childProperty())) {
                        $childName = $relName
                            ->append('_')
                            ->append(
                                $child->relationship()->childProperty()
                            );
                        $this->variables = $this->variables->put(
                            $childName,
                            $changeset->get(
                                $child->relationship()->childProperty()
                            )
                        );
                    }

                    return $carry
                        ->match((string) $name)
                        ->linkedTo(
                            $childName ? (string) $childName : null,
                            $child->labels()->toPrimitive()
                        )
                        ->through(
                            (string) $child->relationship()->type(),
                            (string) $relName
                        );
                }
            );
    }
115545
protected function proceedSubmitRecords(array $changeSet)
    {
        if (is_array($changeSet['submitRecords'] === false)) {
            return;
        }

        foreach ($changeSet['submitRecords'] as $submitRecord) {
            $submitRecordData = array(
                'changeset' => $changeSet['id'],
                'status' => $submitRecord['status'],
            );

            $wherePart = array('changeset' => $changeSet['id']);
            $submitRecordRow = $this->getLookupTableValues(Database::TABLE_SUBMIT_RECORDS, array('id'), $wherePart);
            if ($submitRecordRow === false) {
                $id = $this->getDatabase()->insertRecord(Database::TABLE_SUBMIT_RECORDS, $submitRecordData);

            } else {
                $id = $submitRecordRow['id'];
                $this->getDatabase()->updateRecord(Database::TABLE_SUBMIT_RECORDS, $submitRecordData, $submitRecordRow['id']);
            }

            $submitRecord = $this->unsetKeys($submitRecord, array('status'));

            if (is_array($submitRecord['labels']) === true) {
                $this->proceedSubmitRecordLabels($id, $submitRecord['labels']);
                $submitRecord = $this->unsetKeys($submitRecord, array('labels'));
            }

            $this->checkIfAllValuesWereProceeded($submitRecord, 'Submit record');
        }
    }
677655
private function updateOldAceProperty($name, array $changes)
    {
        list($old, $new) = $changes;
        $currentIds = array();

        for ($i = 0, $c = count($new); $i < $c; ++$i) {
            $ace = $new[$i];

            if (null !== $ace->getId()) {
                $currentIds[$ace->getId()] = true;
            }
        }

        for ($i = 0, $c = count($old); $i < $c; ++$i) {
            $ace = $old[$i];

            if (!isset($currentIds[$ace->getId()])) {
                $this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
                unset($this->loadedAces[$ace->getId()]);
            }
        }
    }
859566
public function updateFieldValueValue(FieldValueInterface $fieldValue, $changeSet)
    {
        if (!isset($changeSet['value'])) {
            return;
        }

        $oldValue = unserialize($changeSet['value'][0]);
        $newValue = unserialize($changeSet['value'][1]);

        if ($newValue['src'] == '' && !$newValue['delete']) {
            $newValue['src'] = $oldValue['src'];
        }

        if ($newValue['delete']) {
            $this->uploadManager->remove($oldValue['src']);
        }

        unset($newValue['delete']);

        $fieldValue->setValue(serialize($newValue));
    }
382296
public function updateRules(RuleSet $ruleSet)
    {
        $this->client->updateRules($this->uri->withPath('.settings/rules'), $ruleSet);
    }
127234
public function applyJoin(
        SelectQuery $query,
        SortClause $sortClause,
        $number,
        array $languageSettings
    ) {
        /** @var \eZ\Publish\API\Repository\Values\Content\Query\SortClause\Target\FieldTarget $fieldTarget */
        $fieldTarget = $sortClause->targetData;
        $fieldMap = $this->contentTypeHandler->getSearchableFieldMap();

        if (!isset($fieldMap[$fieldTarget->typeIdentifier][$fieldTarget->fieldIdentifier]['field_definition_id'])) {
            throw new InvalidArgumentException(
                '$sortClause->targetData',
                'No searchable fields found for the given sort clause target ' .
                "'{$fieldTarget->fieldIdentifier}' on '{$fieldTarget->typeIdentifier}'."
            );
        }

        $fieldDefinitionId = $fieldMap[$fieldTarget->typeIdentifier][$fieldTarget->fieldIdentifier]['field_definition_id'];
        $table = $this->getSortTableName($number);
        $externalTable = $this->getSortTableName($number, 'ezgmaplocation');

        $query
            ->leftJoin(
                $query->alias(
                    $this->dbHandler->quoteTable('ezcontentobject_attribute'),
                    $this->dbHandler->quoteIdentifier($table)
                ),
                $query->expr->lAnd(
                    $query->expr->eq(
                        $query->bindValue($fieldDefinitionId, null, PDO::PARAM_INT),
                        $this->dbHandler->quoteColumn('contentclassattribute_id', $table)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('contentobject_id', $table),
                        $this->dbHandler->quoteColumn('id', 'ezcontentobject')
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('version', $table),
                        $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')
                    ),
                    $this->getFieldCondition($query, $languageSettings, $table)
                )
            )
            ->leftJoin(
                $query->alias(
                    $this->dbHandler->quoteTable('ezgmaplocation'),
                    $this->dbHandler->quoteIdentifier($externalTable)
                ),
                $query->expr->lAnd(
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('contentobject_version', $externalTable),
                        $this->dbHandler->quoteColumn('version', $table)
                    ),
                    $query->expr->eq(
                        $this->dbHandler->quoteColumn('contentobject_attribute_id', $externalTable),
                        $this->dbHandler->quoteColumn('id', $table)
                    )
                )
            );
    }
1297950
protected function proceedCurrentPatchSet(array $changeSet, $currentPatchSetId)
    {
        $currentPatchSet = $changeSet['currentPatchSet'];
        $patchSetRow = $this->getGerritPatchsetByIdentifier(
            $changeSet['id'],
            $currentPatchSet['number'],
            $currentPatchSet['revision'],
            $currentPatchSet['createdOn']
        );

        // If the current currentPatchSet in database not equal the patchset from Gerrit, update it
        if ($patchSetRow['id'] != $currentPatchSetId) {
            $updateData = array('current_patchset' => $patchSetRow['id']);
            $this->getDatabase()->updateRecord(Database::TABLE_CHANGESET, $updateData, $changeSet['id']);
        }
    }
860213
public function updateObject($object, ChangeSet $changeSet) : array
    {
        $changeSet = $this->prepareUpdateChangeSet($object, $changeSet);

        $class      = $this->getClassMetadata();
        $identifier = $this->getObjectIdentifier($object);

        $objectData = $this->objects[$identifier[$class->getIdentifier()[0]]];

        foreach ($changeSet as $key => $value) {
            $objectData[$key] = $value;
        }

        $this->objects[$objectData[$class->getIdentifier()[0]]] = $objectData;

        return $objectData;
    }
842402
private function computeAssociationChanges($document, $class, $oid, $isNew, $changeSet, $assocType)
    {
        switch ($assocType) {
            case 'reference':
                $mappings = $class->referenceMappings;
                $computeMethod = 'computeReferenceChanges';
                break;
            case 'referrer':
                $mappings = $class->referrersMappings;
                $computeMethod = 'computeReferrerChanges';
                break;
            default:
                throw new InvalidArgumentException('Unsupported association type used: '.$assocType);
        }

        foreach ($mappings as $fieldName) {
            $mapping = $class->mappings[$fieldName];

            if ((ClassMetadata::MANY_TO_MANY === $mapping['type'] && 'reference' === $assocType)
                || ('referrers' === $mapping['type'] && 'referrer' === $assocType)
            ) {
                if ($changeSet[$fieldName] instanceof PersistentCollection) {
                    if (!$changeSet[$fieldName]->isInitialized()) {
                        continue;
                    }
                } else {
                    if (null === $changeSet[$fieldName]) {
                        $changeSet[$fieldName] = [];
                    }

                    if (!is_array($changeSet[$fieldName]) && !$changeSet[$fieldName] instanceof Collection) {
                        throw PHPCRException::associationFieldNoArray(
                            self::objToStr($document, $this->dm),
                            $fieldName
                        );
                    }

                    // convert to a PersistentCollection
                    switch ($assocType) {
                        case 'reference':
                            $targetDocument = $mapping['targetDocument'] ?? null;
                            $changeSet[$fieldName] = ReferenceManyCollection::createFromCollection(
                                $this->dm,
                                $document,
                                $mapping['property'],
                                $changeSet[$fieldName],
                                $targetDocument,
                                !$isNew
                            );
                            break;
                        case 'referrer':
                            $referringMeta = $this->dm->getClassMetadata($mapping['referringDocument']);
                            $referringField = $referringMeta->mappings[$mapping['referencedBy']];

                            $changeSet[$fieldName] = ReferrersCollection::createFromCollection(
                                $this->dm,
                                $document,
                                $changeSet[$fieldName],
                                $referringField['strategy'],
                                $referringField['property'],
                                $mapping['referringDocument'],
                                !$isNew
                            );
                            break;
                    }

                    $class->setFieldValue($document, $fieldName, $changeSet[$fieldName]);
                    $this->originalData[$oid][$fieldName] = $changeSet[$fieldName];
                }

                $coid = spl_object_hash($changeSet[$fieldName]);
                $this->visitedCollections[$coid] = $changeSet[$fieldName];

                foreach ($changeSet[$fieldName] as $association) {
                    if ($association !== null) {
                        $this->$computeMethod($mapping, $association);
                    }
                }

                if (!$isNew && $mapping['cascade'] & ClassMetadata::CASCADE_REMOVE) {
                    if (!$this->originalData[$oid][$fieldName] instanceof PersistentCollection) {
                        throw new RuntimeException('OriginalData for a collection association contains something else than a PersistentCollection.');
                    }

                    $associations = $this->originalData[$oid][$fieldName]->getOriginalPaths();
                    foreach ($associations as $association) {
                        $association = $this->getDocumentById($association);
                        if ($association && !$this->originalData[$oid][$fieldName]->contains($association)) {
                            $this->scheduleRemove($association);
                        }
                    }
                }
            } elseif ($changeSet[$fieldName] && ClassMetadata::MANY_TO_ONE === $mapping['type'] && 'reference' === $assocType) {
                $this->computeReferenceChanges($mapping, $changeSet[$fieldName]);
            }
        }
    }
693601
public function updateDataFixutreHistory(array $updateFields, $where, array $parameters = [])
    {
        $qb = $this->_em
            ->createQueryBuilder()
            ->update('OkvpnFixtureBundle:DataFixture', 'm')
            ->where($where);

        foreach ($updateFields as $fieldName => $fieldValue) {
            $qb->set($fieldName, $fieldValue);
        }
        $qb->getQuery()->execute($parameters);
    }
1026634
protected function updateRecordSets(array &$sets)
    {
        if(is_null($this->recordUser)) {
            if(globals()->offsetExists('account')) {
                $this->setRecordUser(globals()->account->id);
            }
        }

        if ( ! isset($sets[ 'record_status' ])) {
            $sets[ 'record_status' ] = $this->recordStatus;
        }

        if ( ! isset($sets[ 'record_update_user' ])) {
            $sets[ 'record_update_user' ] = $this->recordUser;
        }

        $timestamp = $this->unixTimestamp === true ? strtotime(date('Y-m-d H:i:s')) : date('Y-m-d H:i:s');

        if ( ! isset($sets[ 'record_update_timestamp' ])) {
            $sets[ 'record_update_timestamp' ] = $timestamp;
        }
    }
737029
public function ImportDataset($Resultset) {
      if (is_array($Resultset) && array_key_exists(0, $Resultset)) {
         $this->_Cursor = -1;
         $this->_PDOStatement = NULL;
         $FirstRow = $Resultset[0];
			
         if (is_array($FirstRow))
				$this->_DatasetType = DATASET_TYPE_ARRAY;
			else
				$this->_DatasetType = DATASET_TYPE_OBJECT;
			$this->_Result = $Resultset;
      }
   }
310260
public function updateItems(
        Query $query,
        Changes $changes
    ) {
        $this
            ->repository
            ->updateItems(
                $query,
                $changes
            );
    }
1023997
private function applyJoinsAndFilters(ClassMetadata $metadata, string $alias, InputObjectType $typeFields, array $joins, array $conditions): void
    {
        $this->applyJoins($metadata, $joins, $alias);
        $this->collectDqlConditions($metadata, $conditions, $typeFields, $alias);
    }
996044
public function mutate($updateQuery, $options = array())
    {
        if(!is_array($updateQuery)) throw new \Exception('$updateQuery should be an array');
        if(!is_array($options)) throw new \Exception('$options should be an array');

        $default = array(
            'w' => 1
        );
        $options = array_merge($default, $options);

        try {
            $this->_connection->update($this->collectionName(), array('_id' => $this->cleanData['_id']), $updateQuery, $options);
        } catch (\MongoCursorException $e) {
            return false;
        }

        return true;
    }
28774
public function setValueSet($valueSet)
    {
        if (is_string($valueSet)) {
            $valueSet = explode(',', $valueSet);
            $valueSet = array_map('trim', $valueSet);
        }

        $this->valueSet = $valueSet;
    }
851161
private void update() {
        synchronized (lock) {
            if (!observing) { return; }

            try {
                Log.i(DOMAIN, "%s: Querying...", this);
                final ResultSet oldResultSet = resultSet;
                final ResultSet newResultSet = (oldResultSet == null) ? query.execute() : oldResultSet.refresh();

                willUpdate = false;
                lastUpdatedAt = System.currentTimeMillis();

                if (newResultSet != null) {
                    if (oldResultSet != null) { Log.i(DOMAIN, "%s: Changed!", this); }
                    resultSet = newResultSet;
                    changeNotifier.postChange(new QueryChange(this.query, resultSet, null));
                }
                else {
                    Log.i(DOMAIN, "%s: ...no change", this);
                }
            }
            catch (CouchbaseLiteException e) {
                changeNotifier.postChange(new QueryChange(this.query, null, e));
            }
        }
    }