data-table-bundle icon indicating copy to clipboard operation
data-table-bundle copied to clipboard

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

Open Kreyu opened this issue 1 year ago • 0 comments

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 avatar Jan 30 '24 22:01 Kreyu