[6.x] Fix export sorting for joined alias columns#2104
Merged
Conversation
Export queries were resolving sort fields differently from the normal table datasource query. Unqualified sort fields were always prefixed with the root table, so sorting an exported joined/aliased column like `nom_complet` produced `lieu.nom_complet` instead of `nom_complet`. Add a shared sort-field resolver and use it in both datasource sorting and export paths, including queued exports. This keeps qualified fields, table-prefix behavior, and explicit export query options intact. Also add regression coverage for preparing export data sorted by a joined alias column and normalize CSV line endings in the export test helper.
Member
|
Awaiting pint/phpstan fixes |
Contributor
Author
Done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⚡ PowerGrid - Pull Request
Description
This PR fixes export sorting for joined or aliased database columns.
The normal table datasource query and the export query were resolving sort fields differently. The table query respected the existing
ignoreTablePrefixbehavior, so sorting by a selected alias such asnom_completgenerated:The export query always prefixed unqualified sort fields with the root table name, which generated:
That fails because
nom_completis a selected alias, not a real column on the root table.The fix adds a shared sort-field resolver and uses it in the normal database sorting pipeline, synchronous exports, and queued exports. This keeps existing behavior for qualified fields like
categories.name, preserves table-prefix behavior whenignoreTablePrefixis disabled, and keeps explicit export query options intact.This PR also adds regression coverage for preparing export data sorted by a joined alias column.
The CSV export test helper was also adjusted to normalize
\r\n,\n, and\rline endings instead of relying only onPHP_EOL. This makes the test assertion portable across environments and OpenSpout output line endings; it does not change export behavior.Related Issue(s):
Aims to fix #2016
Documentation
This PR requires Documentation update?