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

Implement Doctrine ORM sort property path "guesser" from column property path #58

Open
Kreyu opened this issue Jan 30, 2024 · 0 comments
Assignees
Labels
feature New feature that would fit the core bundle

Comments

@Kreyu
Copy link
Owner

Kreyu commented Jan 30, 2024

Because column property path has syntax specific for Property Access component, and sort property path inherits from it, in some cases, the path would be not supported by the Doctrine. Because of that, bundle should perform some tricks to "guess" a valid DQL:

For example, sorting by the following column:

$builder->addColumn('category', TextColumnType::class, [
    'property_path' => 'category?.name',
    'sort' => true,
]);

currently results in an exception:

[Syntax Error] line 0, col 731: Error: Expected end of string, got '?'

because we're mixing Property Access component syntax with DQL:

# ...
ORDER BY category?.name DESC

With the newly added "guesser", the sorting should be executed on the category.name path, without specifying it manually.

More examples - both property paths should be "guessed" as category.name:

  • [category][name]
  • product?.category[name]
@Kreyu Kreyu added the feature New feature that would fit the core bundle label Jan 30, 2024
@Kreyu Kreyu self-assigned this Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that would fit the core bundle
Projects
None yet
Development

No branches or pull requests

1 participant