Skip to content
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

Fix field name generation and accept string identifier for filter entity #21

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

alioguz
Copy link
Contributor

@alioguz alioguz commented Apr 16, 2024

No description provided.

@alioguz
Copy link
Contributor Author

alioguz commented Jul 31, 2024

@gilles-g Can you review this pull request please ?

@@ -86,7 +87,7 @@ public function filterEntity(GetFilterConditionEvent $event)

if ($dqlFrom = $event->getQueryBuilder()->getDQLPart('from')) {
$rootPart = reset($dqlFrom);
$fieldName = ltrim($event->getField(), $rootPart->getAlias() . '.');
$fieldName = \str_replace(\sprintf('%s.', $rootPart->getAlias()), null, $event->getField());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str_replace works better than ltrim in some case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ltrim method is not correct here. ltrim replace all listing characters and not word.

Example, 2 entities :

  1. Document with alias document
  2. Category with alias category
dump($event->getField()); // document.category
dump($rootPart->getAlias() . '.'); // document.

// Before (wrong)
dump(ltrim($event->getField(), $rootPart->getAlias() . '.')); // ategory

// After (good)
dump(\str_replace(\sprintf('%s.', $rootPart->getAlias()), null, $event->getField())); // category

@gilles-g gilles-g merged commit 1966b3b into SpiriitLabs:master Jul 31, 2024
4 checks passed
@gilles-g
Copy link
Contributor

Thx @alioguz

gilles-g pushed a commit that referenced this pull request Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants