@@ -8320,94 +8320,94 @@ public function decode(QueryContext $context, Document $document, array $selects
83208320 return $ document ;
83218321 }
83228322
8323- // public function decode(QueryContext $context, Document $document, array $selects = []): Document
8324- // {
8325- // $internals = [];
8326- // $schema = [];
8327- //
8328- // foreach (Database::INTERNAL_ATTRIBUTES as $attribute) {
8329- // $internals[$attribute['$id']] = $attribute;
8330- // }
8331- //
8332- // foreach ($context->getCollections() as $collection) {
8333- // foreach ($collection->getAttribute('attributes', []) as $attribute) {
8334- // $key = $attribute->getAttribute('key', $attribute->getAttribute('$id'));
8335- // $key = $this->adapter->filter($key);
8336- // $schema[$collection->getId()][$key] = $attribute->getArrayCopy();
8337- // }
8338- // }
8339- //
8340- // $new = $this->createDocumentInstance($context->getMainCollection()->getId(), []);
8341- //
8342- // foreach ($document as $key => $value) {
8343- // $alias = Query::DEFAULT_ALIAS;
8344- // $attributeKey = '';
8345- //
8346- // foreach ($selects as $select) {
8347- // if ($select->getAs() === $key) {
8348- // $attributeKey = $key;
8349- // $key = $select->getAttribute();
8350- // $alias = $select->getAlias();
8351- //
8352- // break;
8353- // }
8354- //
8355- // if ($select->getAttribute() == $key || $this->adapter->filter($select->getAttribute()) == $key) {
8356- // $alias = $select->getAlias();
8357- //
8358- // break;
8359- // }
8360- // }
8361- //
8362- // $collection = $context->getCollectionByAlias($alias);
8363- // if ($collection->isEmpty()) {
8364- // throw new \Exception('Invalid query: Unknown Alias context');
8365- // }
8366- //
8367- // $attribute = $internals[$key] ?? null;
8368- //
8369- // if (is_null($attribute)) {
8370- // $attribute = $schema[$collection->getId()][$this->adapter->filter($key)] ?? null;
8371- // }
8372- //
8373- // if (is_null($attribute)) {
8374- // if (!$this->adapter->getSupportForAttributes()) {
8375- // $new->setAttribute($key, $value); /** Schemaless */
8376- // }
8377- //
8378- // continue;
8379- // }
8380- //
8381- // if (empty($attributeKey)) {
8382- // $attributeKey = $attribute['$id'];
8383- // }
8384- //
8385- // $array = $attribute['array'] ?? false;
8386- // $filters = $attribute['filters'] ?? [];
8387- //
8388- // // Skip decoding for Operator objects (shouldn't happen, but safety check)
8389- // if ($value instanceof Operator) {
8390- // continue;
8391- // }
8392- //
8393- // $value = ($array) ? $value : [$value];
8394- // $value = (is_null($value)) ? [] : $value;
8395- //
8396- // foreach ($value as $index => $node) {
8397- // foreach (\array_reverse($filters) as $filter) {
8398- // $node = $this->decodeAttribute($filter, $node, $new, $key);
8399- // }
8400- //
8401- // $value[$index] = $node;
8402- // }
8403- //
8404- // $value = ($array) ? $value : $value[0];
8405- //
8406- // $new->setAttribute($attributeKey, $value);
8407- // }
8408- //
8409- // return $new;
8410- // }
8323+ // public function decode(QueryContext $context, Document $document, array $selects = []): Document
8324+ // {
8325+ // $internals = [];
8326+ // $schema = [];
8327+ //
8328+ // foreach (Database::INTERNAL_ATTRIBUTES as $attribute) {
8329+ // $internals[$attribute['$id']] = $attribute;
8330+ // }
8331+ //
8332+ // foreach ($context->getCollections() as $collection) {
8333+ // foreach ($collection->getAttribute('attributes', []) as $attribute) {
8334+ // $key = $attribute->getAttribute('key', $attribute->getAttribute('$id'));
8335+ // $key = $this->adapter->filter($key);
8336+ // $schema[$collection->getId()][$key] = $attribute->getArrayCopy();
8337+ // }
8338+ // }
8339+ //
8340+ // $new = $this->createDocumentInstance($context->getMainCollection()->getId(), []);
8341+ //
8342+ // foreach ($document as $key => $value) {
8343+ // $alias = Query::DEFAULT_ALIAS;
8344+ // $attributeKey = '';
8345+ //
8346+ // foreach ($selects as $select) {
8347+ // if ($select->getAs() === $key) {
8348+ // $attributeKey = $key;
8349+ // $key = $select->getAttribute();
8350+ // $alias = $select->getAlias();
8351+ //
8352+ // break;
8353+ // }
8354+ //
8355+ // if ($select->getAttribute() == $key || $this->adapter->filter($select->getAttribute()) == $key) {
8356+ // $alias = $select->getAlias();
8357+ //
8358+ // break;
8359+ // }
8360+ // }
8361+ //
8362+ // $collection = $context->getCollectionByAlias($alias);
8363+ // if ($collection->isEmpty()) {
8364+ // throw new \Exception('Invalid query: Unknown Alias context');
8365+ // }
8366+ //
8367+ // $attribute = $internals[$key] ?? null;
8368+ //
8369+ // if (is_null($attribute)) {
8370+ // $attribute = $schema[$collection->getId()][$this->adapter->filter($key)] ?? null;
8371+ // }
8372+ //
8373+ // if (is_null($attribute)) {
8374+ // if (!$this->adapter->getSupportForAttributes()) {
8375+ // $new->setAttribute($key, $value); /** Schemaless */
8376+ // }
8377+ //
8378+ // continue;
8379+ // }
8380+ //
8381+ // if (empty($attributeKey)) {
8382+ // $attributeKey = $attribute['$id'];
8383+ // }
8384+ //
8385+ // $array = $attribute['array'] ?? false;
8386+ // $filters = $attribute['filters'] ?? [];
8387+ //
8388+ // // Skip decoding for Operator objects (shouldn't happen, but safety check)
8389+ // if ($value instanceof Operator) {
8390+ // continue;
8391+ // }
8392+ //
8393+ // $value = ($array) ? $value : [$value];
8394+ // $value = (is_null($value)) ? [] : $value;
8395+ //
8396+ // foreach ($value as $index => $node) {
8397+ // foreach (\array_reverse($filters) as $filter) {
8398+ // $node = $this->decodeAttribute($filter, $node, $new, $key);
8399+ // }
8400+ //
8401+ // $value[$index] = $node;
8402+ // }
8403+ //
8404+ // $value = ($array) ? $value : $value[0];
8405+ //
8406+ // $new->setAttribute($attributeKey, $value);
8407+ // }
8408+ //
8409+ // return $new;
8410+ // }
84118411
84128412 /**
84138413 * Casting
0 commit comments