Skip to content

Commit

Permalink
Add support for using nested DTOs
Browse files Browse the repository at this point in the history
This feature allow use of nested new operators
  • Loading branch information
eltharin committed Jul 5, 2024
1 parent 2c24349 commit 8e30b88
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ protected function hydrateRowData(array $row, array &$result): void
$scalarCount = (isset($rowData['scalars']) ? count($rowData['scalars']) : 0);

foreach ($rowData['newObjects'] as $objIndex => $newObject) {
$obj = $newObject['obj'] ?? null;
$obj = $newObject['obj'];

if ($scalarCount === 0 && count($rowData['newObjects']) === 1) {
$result[$resultKey] = $obj;
Expand Down
4 changes: 1 addition & 3 deletions src/Query/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1675,9 +1675,7 @@ public function NewObjectArg(): mixed
}

if ($token->type === TokenType::T_NEW) {
$expression = $this->NewObjectExpression();

return $expression;
return $this->NewObjectExpression();
}

return $this->ScalarExpression();
Expand Down
2 changes: 1 addition & 1 deletion src/Query/ResultSetMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public function addNewObjectAsArgument(string|int $alias, string|int $objOwner,

$this->nestedNewObjectArguments = array_merge(
[$alias => $owner],
$this->nestedNewObjectArguments
$this->nestedNewObjectArguments,
);

return $this;
Expand Down
1 change: 0 additions & 1 deletion src/Query/SqlWalker.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class SqlWalker
*/
private int $newObjectCounter = 0;


/**
* Contains nesting levels of new objects arguments
*
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/Models/DDC6573/DDC6573Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public function getCode(): string
{
return $this->code;
}
}
}
2 changes: 1 addition & 1 deletion tests/Tests/Models/DDC6573/DDC6573Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ public function getPrice(): DDC6573Money
{
return new DDC6573Money($this->priceAmount, new DDC6573Currency($this->priceCurrency));
}
}
}
2 changes: 1 addition & 1 deletion tests/Tests/Models/DDC6573/DDC6573Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public function getCurrency(): DDC6573Currency
{
return $this->currency;
}
}
}
2 changes: 1 addition & 1 deletion tests/Tests/ORM/Functional/Ticket/DDC6573Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ public function testShouldSupportsBasicUsage(int $hydrationMode): void
self::assertEquals($this->fixtures[1]->getPrice()->getCurrency(), $result[2]);
self::assertEquals($this->fixtures[2]->getPrice()->getCurrency(), $result[1]);
}
}
}

0 comments on commit 8e30b88

Please sign in to comment.