Package
filament/filament
Package Version
v3.2.116
Laravel Version
v11.29.0
Livewire Version
v3.5.12
PHP Version
PHP 8.2.22
Problem description
When exporting data to CSV using Filament's Export action, the global sorting order is not maintained when the data is processed in chunks. This issue has been observed with PostgreSQL under these conditions:
- The chunk size is smaller than the total number of records
- Any sort order is applied, whether through:
- Custom sort via
modifyQueryUsing()
- Default table sort configuration
- User-triggered column sorting in the Filament table
Importantly, the sorting works correctly when the chunk size is larger than the total number of records, confirming this is specifically a chunking issue rather than a general sorting problem.
Current workaround:
- Setting the chunk size larger than the total number of records resolves the issue
- However, this is not a scalable solution for large datasets
Additional context:
The issue appears to be related to how ORDER BY clauses are handled during chunked queries. The fact that the sorting works correctly when processing all records in a single chunk suggests that the chunking mechanism isn't properly maintaining the global sort order when splitting the data.
This affects all sorting methods available in Filament:
- Default table sorting
- Interactive column sorting
- Custom query modifications
This might require either:
- A modification to how chunks are processed to maintain global order
- A database-specific implementation of the chunking strategy
- A warning in the documentation about this limitation
Environment:
- Database: PostgreSQL 14.x
- Records: Works correctly when chunk size > total records
- Sorting: Affects all available sorting methods in Filament
Expected behavior
The CSV export should maintain a consistent global sort order regardless of:
- The chunk size used
- The total number of records
- How the sort order was specified (default table sort, column sorting, or custom sort)
- The specific sort order applied
The chunking process should preserve the global ordering while still allowing for efficient processing of large datasets.
Steps to reproduce
See ReadMe in Reproduction repository.
Reproduction repository (issue will be closed if this is not valid)
https://github.com/kaspernowak/filament-issue
Relevant log output
No response
Package
filament/filament
Package Version
v3.2.116
Laravel Version
v11.29.0
Livewire Version
v3.5.12
PHP Version
PHP 8.2.22
Problem description
When exporting data to CSV using Filament's Export action, the global sorting order is not maintained when the data is processed in chunks. This issue has been observed with PostgreSQL under these conditions:
modifyQueryUsing()Importantly, the sorting works correctly when the chunk size is larger than the total number of records, confirming this is specifically a chunking issue rather than a general sorting problem.
Current workaround:
Additional context:
The issue appears to be related to how ORDER BY clauses are handled during chunked queries. The fact that the sorting works correctly when processing all records in a single chunk suggests that the chunking mechanism isn't properly maintaining the global sort order when splitting the data.
This affects all sorting methods available in Filament:
This might require either:
Environment:
Expected behavior
The CSV export should maintain a consistent global sort order regardless of:
The chunking process should preserve the global ordering while still allowing for efficient processing of large datasets.
Steps to reproduce
See ReadMe in Reproduction repository.
Reproduction repository (issue will be closed if this is not valid)
https://github.com/kaspernowak/filament-issue
Relevant log output
No response