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

Closed
opened 2026-05-14 03:48:53 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/6776
Author: @nicegamer7
Created: 1/25/2026
Status: Closed

Base: masterHead: fix-same-day-transactions-import


📝 Commits (1)

  • e57f02e set sort_order while importing same-day transactions

📊 Changes

4 files changed (+61 additions, -10 deletions)

View changed files

📝 packages/loot-core/src/server/__snapshots__/main.test.ts.snap (+2 -2)
📝 packages/loot-core/src/server/accounts/sync.test.ts (+38 -1)
📝 packages/loot-core/src/server/accounts/sync.ts (+9 -1)
📝 packages/loot-core/src/server/transactions/index.ts (+12 -6)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/6776 **Author:** [@nicegamer7](https://github.com/nicegamer7) **Created:** 1/25/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix-same-day-transactions-import` --- ### 📝 Commits (1) - [`e57f02e`](https://github.com/actualbudget/actual/commit/e57f02ecb058d5de2c96c6503108b9d51912f2c0) set sort_order while importing same-day transactions ### 📊 Changes **4 files changed** (+61 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/server/__snapshots__/main.test.ts.snap` (+2 -2) 📝 `packages/loot-core/src/server/accounts/sync.test.ts` (+38 -1) 📝 `packages/loot-core/src/server/accounts/sync.ts` (+9 -1) 📝 `packages/loot-core/src/server/transactions/index.ts` (+12 -6) </details> ### 📄 Description <!-- 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-14 03:48:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#69099