@@ -5746,57 +5746,91 @@ public function find(string $collection, array $queries = [], string $forPermiss
57465746
57475747 //$filters = self::convertQueries($collection, $filters);
57485748
5749- /** @var array<Query> $queries */
5750- $ queries = \array_merge (
5751- $ selects ,
5752- $ filters
5753- );
5749+ // /** @var array<Query> $queries */
5750+ // $queries = \array_merge(
5751+ // $selects,
5752+ // $filters
5753+ // );
57545754
57555755 $ selections = $ this ->validateSelections ($ collection , $ selects );
57565756 $ nestedSelections = [];
57575757
5758- foreach ($ queries as $ index => &$ query ) {
5759- switch ($ query ->getMethod ()) {
5760- case Query::TYPE_SELECT :
5761- $ values = $ query ->getValues ();
5762- foreach ($ values as $ valueIndex => $ value ) {
5763- if (\str_contains ($ value , '. ' )) {
5764- // Shift the top level off the dot-path to pass the selection down the chain
5765- // 'foo.bar.baz' becomes 'bar.baz'
5766- $ nestedSelections [] = Query::select ([
5767- \implode ('. ' , \array_slice (\explode ('. ' , $ value ), 1 ))
5768- ]);
5758+ foreach ($ selects as $ i => $ q ) {
5759+ var_dump ($ q ->getAlias ());
5760+ var_dump ($ q ->getAttribute ());
5761+ if (\str_contains ($ q ->getAttribute (), '. ' )) {
5762+ $ nestedSelections [] = Query::select (
5763+ \implode ('. ' , \array_slice (\explode ('. ' , $ q ->getAttribute ()), 1 ))
5764+ );
57695765
5770- $ key = \explode ('. ' , $ value )[0 ];
5766+ $ key = \explode ('. ' , $ q -> getAttribute () )[0 ];
57715767
5772- foreach ($ relationships as $ relationship ) {
5773- if ($ relationship ->getAttribute ('key ' ) === $ key ) {
5774- switch ($ relationship ->getAttribute ('options ' )['relationType ' ]) {
5775- case Database::RELATION_MANY_TO_MANY :
5776- case Database::RELATION_ONE_TO_MANY :
5777- unset($ values [$ valueIndex ]);
5778- break ;
5768+ var_dump ('#################################### ' );
5769+ var_dump ($ key );
5770+ var_dump ('#################################### ' );
5771+ foreach ($ relationships as $ relationship ) {
5772+ if ($ relationship ->getAttribute ('key ' ) === $ key ) {
5773+ switch ($ relationship ->getAttribute ('options ' )['relationType ' ]) {
5774+ case Database::RELATION_MANY_TO_MANY :
5775+ case Database::RELATION_ONE_TO_MANY :
5776+ unset($ selects [$ i ]);
5777+ break ;
57795778
5780- case Database::RELATION_MANY_TO_ONE :
5781- case Database::RELATION_ONE_TO_ONE :
5782- $ values [$ valueIndex ] = $ key ;
5783- break ;
5784- }
5785- }
5786- }
5779+ case Database::RELATION_MANY_TO_ONE :
5780+ case Database::RELATION_ONE_TO_ONE :
5781+ $ q ->setAttribute ($ key );
5782+ $ selects [$ i ] = $ q ;
5783+ break ;
57875784 }
57885785 }
5789- $ query ->setValues (\array_values ($ values ));
5790- break ;
5791- default :
5792- if (\str_contains ($ query ->getAttribute (), '. ' )) {
5793- unset($ queries [$ index ]);
5794- }
5795- break ;
5786+ }
57965787 }
57975788 }
57985789
5799- $ queries = \array_values ($ queries );
5790+ $ selects = \array_values ($ selects ); // Since we may unset above
5791+
5792+ // foreach ($queries as $index => &$query) {
5793+ // switch ($query->getMethod()) {
5794+ // case Query::TYPE_SELECT:
5795+ // $values = $query->getValues();
5796+ // foreach ($values as $valueIndex => $value) {
5797+ // if (\str_contains($value, '.')) {
5798+ // // Shift the top level off the dot-path to pass the selection down the chain
5799+ // // 'foo.bar.baz' becomes 'bar.baz'
5800+ // $nestedSelections[] = Query::select([
5801+ // \implode('.', \array_slice(\explode('.', $value), 1))
5802+ // ]);
5803+ //
5804+ // $key = \explode('.', $value)[0];
5805+ //
5806+ // foreach ($relationships as $relationship) {
5807+ // if ($relationship->getAttribute('key') === $key) {
5808+ // switch ($relationship->getAttribute('options')['relationType']) {
5809+ // case Database::RELATION_MANY_TO_MANY:
5810+ // case Database::RELATION_ONE_TO_MANY:
5811+ // unset($values[$valueIndex]);
5812+ // break;
5813+ //
5814+ // case Database::RELATION_MANY_TO_ONE:
5815+ // case Database::RELATION_ONE_TO_ONE:
5816+ // $values[$valueIndex] = $key;
5817+ // break;
5818+ // }
5819+ // }
5820+ // }
5821+ // }
5822+ // }
5823+ // $query->setValues(\array_values($values));
5824+ // break;
5825+ // default:
5826+ // if (\str_contains($query->getAttribute(), '.')) {
5827+ // unset($queries[$index]);
5828+ // }
5829+ // break;
5830+ // }
5831+ // }
5832+ //
5833+ // $queries = \array_values($queries);
58005834
58015835 $ results = $ this ->adapter ->find (
58025836 $ context ,
0 commit comments