Skip to content

Conversation

@rishiraj-58
Copy link

@rishiraj-58 rishiraj-58 commented Nov 19, 2025

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 commonFields object in buildBaseUnionQuery() method had columns ordered as { createdAt, updatedAt, ... }, but the actual entity columns (defined by the WithTimestamps base 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

  • Reordered commonFields in workflow.repository.ts line 151-156 to match the actual entity column order
  • Changed from { createdAt: true, updatedAt: true, ... } to { updatedAt: true, createdAt: true, ... }

Testing Results

Before fix:

  • Clicking "Sort by last updated" → workflows sorted by creation date ❌
  • Clicking "Sort by last created" → workflows sorted by update date ❌

After fix:

  • Clicking "Sort by last updated" → workflows sorted by update date ✅
  • Clicking "Sort by last created" → workflows sorted by creation date ✅

Test Steps:

  1. Navigate to workflows page
  2. Create or update several workflows at different times
  3. Test "Sort by last updated" - should show most recently updated first
  4. Test "Sort by last created" - should show most recently created first
  5. Verify "Last updated" timestamps match the sort order

Notes

Related Linear tickets, Github issues, and Community forum posts

Closes #22016

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

Note

Reorders commonFields in workflow.repository.ts so updatedAt precedes createdAt, 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.

The commonFields object in buildBaseUnionQuery had createdAt before updatedAt,
but the actual entity columns (from WithTimestamps base class) have updatedAt
before createdAt. This mismatch caused the UNION query to swap data between
these columns, resulting in reversed sorting behavior.

Fixed by reordering commonFields to match the actual entity column order.

Resolves sorting issue where 'Sort by last updated' was sorting by creation
date and 'Sort by last created' was sorting by update date.
@n8n-assistant n8n-assistant bot added community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels Nov 19, 2025
@n8n-assistant
Copy link

n8n-assistant bot commented Nov 19, 2025

Hey @rishiraj-58,

Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request.

Before we can proceed, please ensure the following:
• Tests are included for any new functionality, logic changes or bug fixes.
• The PR aligns with our contribution guidelines.

Regarding new nodes:
We no longer accept new nodes directly into the core codebase. Instead, we encourage contributors to follow our Community Node Submission Guide to publish nodes independently.

If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach.

About review timelines:
This PR has been added to our internal tracker as "GHC-5555". While we plan to review it, we are currently unable to provide an exact timeframe. Our goal is to begin reviews within a month, but this may change depending on team priorities. We will reach out when the review begins.

Thank you again for contributing to n8n.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community member in linear Issue or PR has been created in Linear for internal review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sorting flows by last updated doesn't work

1 participant