-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search] Allow Searching in nested ORM\Embedded property #3898
base: 4.x
Are you sure you want to change the base?
[Search] Allow Searching in nested ORM\Embedded property #3898
Conversation
$propertyMetadata = $associatedEntityDto->getPropertyMetadata($associatedPropertyName); | ||
$targetEntity = $propertyMetadata->get('targetEntity'); | ||
$associatedEntityDto = $this->entityFactory->create($targetEntity); | ||
} catch (\InvalidArgumentException $exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if fails to find metadata
$targetEntity = $propertyMetadata->get('targetEntity'); | ||
$associatedEntityDto = $this->entityFactory->create($targetEntity); | ||
} catch (\InvalidArgumentException $exception) { | ||
if ($this->isNestedEmbbededProperty($associatedProperties)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try embeddable
52c698d
to
648d9c4
Compare
$targetEntity = $propertyMetadata->get('targetEntity'); | ||
$associatedEntityDto = $this->entityFactory->create($targetEntity); | ||
try { | ||
$propertyMetadata = $associatedEntityDto->getPropertyMetadata($associatedPropertyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep old behavior
I wanted to unit test it. But |
a.b.c where b is a ORM\Embedded
648d9c4
to
ed9ef98
Compare
Code was hard codded to fail if nested properties But was failing with Doctrine ORM\Embedded too
@@ -21,7 +21,7 @@ public function supports(FieldDto $field, EntityDto $entityDto): bool | |||
public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $context): void | |||
{ | |||
$isRenderedAsSwitch = true === $field->getCustomOption(BooleanField::OPTION_RENDER_AS_SWITCH); | |||
if ($isRenderedAsSwitch && false !== strpos($field->getProperty(), '.')) { | |||
if ($isRenderedAsSwitch && $this->isNestedProperty($field) && false === $this->isBoolean($field)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was crashing the app during EDIT on boolean Doctrine Embedded properties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to search? Seems like you are not fixing it but just ignoring it, or am I wrong?
I guess the AJAX request to change the value will not work with this change? Maybe remove this change and render the property as a normal boolean field, like the exception message says?
Pain Point
Thanks to #3864 you can now search on nested entities 🚀.

But if you try to search on an Entity which has nested Embedable you might have this error
CRUD config:

Usecase:
property
(ORM\ManyToOne)landlord
(ORM\ManyToOne)person1
(ORM\Embedded)firstName
(string)It fails to find

person1
since onlyperson1.firstName
is mapped inlandlord
.TODO