[PR #6776] [WIP] Fix sort order of imported same-day transactions #6732

Closed
opened 2026-02-28 21:32:00 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/6776

State: closed
Merged: No


Fixes #6588.

The problem was caused by the fact that imports happen really quickly, which means that the default value of sort_order (milliseconds timestamp) usually ends up being the same for most of the imported transactions. We then fallback to sorting by id, which is just a UUID, so the order does not reflect the order that the transactions were added in.

This PR makes it so that we explicitly set sort_order when adding/importing transactions. This has the added benefit of allowing us to keep the Promise.all. I was debating an alternate solution where we fallback to sorting by rowid instead of id, but there were some downsides:

  • If rowid is not explicitly defined on the table, the values of the entire rowid column can change when running a VACUUM statement
  • If using rowid, we must ensure that transactions are added in the same order we received them (i.e. not in parallel)
**Original Pull Request:** https://github.com/actualbudget/actual/pull/6776 **State:** closed **Merged:** No --- <!-- Thank you for submitting a pull request! Make sure to follow the instructions to write release notes for your PR — it should only take a minute or two: https://github.com/actualbudget/docs#writing-good-release-notes. Try running yarn generate:release-notes *before* pushing your PR for an interactive experience. --> Fixes #6588. The problem was caused by the fact that imports happen really quickly, which means that the default value of `sort_order` (milliseconds timestamp) usually ends up being the same for most of the imported transactions. We then fallback to sorting by `id`, which is just a UUID, so the order does not reflect the order that the transactions were added in. This PR makes it so that we explicitly set `sort_order` when adding/importing transactions. This has the added benefit of allowing us to keep the `Promise.all`. I was debating an alternate solution where we fallback to sorting by [`rowid`](https://www.sqlite.org/lang_createtable.html#rowid) instead of `id`, but there were some downsides: - If `rowid` is not explicitly defined on the table, the values of the entire `rowid` column can change when running a [`VACUUM`](https://sqlite.org/lang_vacuum.html) statement - If using `rowid`, we must ensure that transactions are added in the same order we received them (i.e. not in parallel)
GiteaMirror added the pull-request label 2026-02-28 21:32:00 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#6732