fix: correct column order in workflow UNION query to fix sorting #22026
+1
−1
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.
Summary
This PR fixes the reversed workflow sorting behavior where "Sort by last updated" was sorting by creation date and "Sort by last created" was sorting by update date.
Root Cause
The
commonFieldsobject inbuildBaseUnionQuery()method had columns ordered as{ createdAt, updatedAt, ... }, but the actual entity columns (defined by theWithTimestampsbase class) are ordered as{ updatedAt, createdAt, ... }. This mismatch caused the SQL UNION query to swap data between these two columns when fetching workflows and folders together.Changes
commonFieldsinworkflow.repository.tsline 151-156 to match the actual entity column order{ createdAt: true, updatedAt: true, ... }to{ updatedAt: true, createdAt: true, ... }Testing Results
Before fix:
After fix:
Test Steps:
Notes
Related Linear tickets, Github issues, and Community forum posts
Closes #22016
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)Note
Reorders
commonFieldsinworkflow.repository.tssoupdatedAtprecedescreatedAt, aligning UNION select column order to map timestamps correctly and fix sorting by updated/created.Written by Cursor Bugbot for commit 8c05171. This will update automatically on new commits. Configure here.