Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: internal error on pin/unpin (#4332)

Viacheslav Potoropin7ed3a12a6467
diff --git a/store/db/mysql/memo.go b/store/db/mysql/memo.go
index 4fe928f95..40549bc7f 100644
--- a/store/db/mysql/memo.go
+++ b/store/db/mysql/memo.go
@@ -242,6 +242,9 @@ func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
}
set, args = append(set, "`payload` = ?"), append(args, string(payloadBytes))
}
+ if len(args) == 0 {
+ return nil
+ }
args = append(args, update.ID)
stmt := "UPDATE `memo` SET " + strings.Join(set, ", ") + " WHERE `id` = ?"
diff --git a/store/db/postgres/memo.go b/store/db/postgres/memo.go
index be4b35589..268fb1441 100644
--- a/store/db/postgres/memo.go
+++ b/store/db/postgres/memo.go
@@ -233,6 +233,9 @@ func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
}
set, args = append(set, "payload = "+placeholder(len(args)+1)), append(args, string(payloadBytes))
}
+ if len(args) == 0 {
+ return nil
+ }
stmt := `UPDATE memo SET ` + strings.Join(set, ", ") + ` WHERE id = ` + placeholder(len(args)+1)
args = append(args, update.ID)
diff --git a/store/db/sqlite/memo.go b/store/db/sqlite/memo.go
index a983a388d..87da7f19a 100644
--- a/store/db/sqlite/memo.go
+++ b/store/db/sqlite/memo.go
@@ -220,6 +220,9 @@ func (d *DB) UpdateMemo(ctx context.Context, update *store.UpdateMemo) error {
}
set, args = append(set, "`payload` = ?"), append(args, string(payloadBytes))
}
+ if len(args) == 0 {
+ return nil
+ }
args = append(args, update.ID)
stmt := "UPDATE `memo` SET " + strings.Join(set, ", ") + " WHERE `id` = ?"