From e35f16306ed95b2b11522bc7f2ea636752bae1c0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Oct 2025 19:44:41 +0800 Subject: [PATCH] feat: add id as final tie-breaker in ListMemos --- store/db/mysql/memo.go | 2 ++ store/db/postgres/memo.go | 2 ++ store/db/sqlite/memo.go | 2 ++ store/seed/sqlite/01__dump.sql | 6 +++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/store/db/mysql/memo.go b/store/db/mysql/memo.go index 41f2bb950..2f9bc2ebb 100644 --- a/store/db/mysql/memo.go +++ b/store/db/mysql/memo.go @@ -114,6 +114,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo } else { orderBy = append(orderBy, "`created_ts` "+order) } + // Add id as final tie-breaker + orderBy = append(orderBy, "`id` DESC") fields := []string{ "`memo`.`id` AS `id`", "`memo`.`uid` AS `uid`", diff --git a/store/db/postgres/memo.go b/store/db/postgres/memo.go index 6a53e1293..ac4da8f25 100644 --- a/store/db/postgres/memo.go +++ b/store/db/postgres/memo.go @@ -105,6 +105,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo } else { orderBy = append(orderBy, "created_ts "+order) } + // Add id as final tie-breaker + orderBy = append(orderBy, "id DESC") fields := []string{ `memo.id AS id`, `memo.uid AS uid`, diff --git a/store/db/sqlite/memo.go b/store/db/sqlite/memo.go index b3c0ee35a..f3bc2f54d 100644 --- a/store/db/sqlite/memo.go +++ b/store/db/sqlite/memo.go @@ -106,6 +106,8 @@ func (d *DB) ListMemos(ctx context.Context, find *store.FindMemo) ([]*store.Memo } else { orderBy = append(orderBy, "`created_ts` "+order) } + // Add id as final tie-breaker + orderBy = append(orderBy, "`id` DESC") fields := []string{ "`memo`.`id` AS `id`", "`memo`.`uid` AS `uid`", diff --git a/store/seed/sqlite/01__dump.sql b/store/seed/sqlite/01__dump.sql index 7cc558778..43be4cf6c 100644 --- a/store/seed/sqlite/01__dump.sql +++ b/store/seed/sqlite/01__dump.sql @@ -5,7 +5,7 @@ INSERT INTO memo (id,uid,creator_id,content,visibility,payload) VALUES(3,'8x7bm2 INSERT INTO memo (id,uid,creator_id,content,visibility,payload) VALUES(4,'kBfJKAyFvE52kQ9dmSZMfE',1,'Wow, it can be **referenced** too! REALLY GREAT!!! #features','PUBLIC','{"tags":["features"]}'); INSERT INTO memo (id,uid,creator_id,content,visibility,pinned,payload) VALUES(5,'RF9XnAcWpcBzKttK83zQtf',1,replace('#sponsor **[Warp](https://go.warp.dev/memos)**: A modern terminal reimagined to work with AI, helping developers build faster and more efficiently.\n[![Warp](https://raw.githubusercontent.com/warpdotdev/brand-assets/main/Github/Sponsor/Warp-Github-LG-02.png)](https://go.warp.dev/memos)','\n',char(10)),'PUBLIC',1,'{"tags":["sponsor"],"property":{"hasLink":true}}'); INSERT INTO memo_relation VALUES(4,1,'REFERENCE'); -INSERT INTO reaction VALUES(1,1722097094,1,'memos/4','👍'); -INSERT INTO reaction VALUES(2,1722097100,1,'memos/4','🔥'); -INSERT INTO reaction VALUES(3,1722097101,1,'memos/4','+1'); +INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(1,1,'memos/4','👍'); +INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(2,1,'memos/4','🔥'); +INSERT INTO reaction (id,creator_id,content_id,reaction_type) VALUES(3,1,'memos/4','+1'); INSERT INTO system_setting VALUES ('MEMO_RELATED', '{"contentLengthLimit":8192,"enableAutoCompact":true,"enableComment":true,"enableLocation":true,"defaultVisibility":"PUBLIC","reactions":["👍","💛","🔥","👏","😂","👌","🚀","👀","🤔","🤡","❓","+1"]}', '');