From 353f01b23f8c57843af33342f897dce04ab756d9 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Wed, 7 May 2025 22:20:50 +0200 Subject: [PATCH] fix wrong column name in attachment sql query --- application/attachment.c | 2 +- application/gtk-text.c | 2 +- application/note.c | 2 +- application/store.c | 4 ++-- application/types.c | 3 ++- application/types.h | 3 ++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/application/attachment.c b/application/attachment.c index c5cf9ba..f222c21 100644 --- a/application/attachment.c +++ b/application/attachment.c @@ -43,7 +43,7 @@ Attachment* attachment_create( { Attachment *attachment = cxCalloc(a, 1, sizeof(Attachment)); attachment->parent_resource_id = parent; - attachment->name = cx_strdup_a(a, cx_str(name)).ptr; + attachment->nodename = cx_strdup_a(a, cx_str(name)).ptr; attachment->type = type; return attachment; } diff --git a/application/gtk-text.c b/application/gtk-text.c index cd896fd..9cc5de1 100644 --- a/application/gtk-text.c +++ b/application/gtk-text.c @@ -316,7 +316,7 @@ static gboolean editor_attach_file(NoteEditor *editor, const char *path) { void md_serialize_image(EmbeddedWidget *em, CxBuffer *out) { Attachment *attachment = em->data1; // TODO: relative path to parent resource - char *path = util_url_encode(NULL, attachment->name); + char *path = util_url_encode(NULL, attachment->nodename); cx_bprintf(out, "![image](%s)", path); free(path); } diff --git a/application/note.c b/application/note.c index e19cd27..06ff6a3 100644 --- a/application/note.c +++ b/application/note.c @@ -295,7 +295,7 @@ Attachment* note_get_attachment(Resource *note, const char *path) { CxIterator i = cxListIterator(note->attachments); cx_foreach(Attachment *, attachment, i) { // TODO: support path, not just the name - if(!strcmp(attachment->name, path)) { + if(!strcmp(attachment->nodename, path)) { return attachment; } } diff --git a/application/store.c b/application/store.c index 8d9b392..2c82211 100644 --- a/application/store.c +++ b/application/store.c @@ -78,7 +78,7 @@ #define SQL_ATTACHMENT_NEW "insert into attachments(attachment_resource_id, parent_resource_id, type) values (?, ?, ?) returning attachment_id;" #define SQL_ATTACHMENTS_GET "select attachment_id, attachment_resource_id, parent_resource_id, a.type, "\ - "r.name, r.content from attachments a "\ + "r.nodename, r.displayname, r.content from attachments a "\ "inner join resources r on a.attachment_resource_id = r.resource_id " \ "where parent_resource_id = ? order by attachment_id;" @@ -701,7 +701,7 @@ void note_store_save_attachment_async(UiObject *obj, Attachment *attachment, exe job->resource_id = attachment->parent_resource_id; job->attachment_id = attachment->attachment_id; job->type = attachment->type; - job->name = strdup(attachment->name); + job->name = strdup(attachment->nodename); job->content = attachment->content.ptr ? cx_strdup(cx_strcast(attachment->content)) : (cxmutstr){NULL, 0}; job->resultcb = resultcb; job->error = 0; diff --git a/application/types.c b/application/types.c index 57db2a7..f0f5341 100644 --- a/application/types.c +++ b/application/types.c @@ -83,6 +83,7 @@ void register_types() { dbuClassAdd(attachments_class, Attachment, attachment_resource_id); dbuClassAdd(attachments_class, Attachment, parent_resource_id); dbuClassAdd(attachments_class, Attachment, type); - dbuClassAdd(attachments_class, Attachment, name); + dbuClassAdd(attachments_class, Attachment, nodename); + dbuClassAdd(attachments_class, Attachment, displayname); dbuClassAdd(attachments_class, Attachment, content); } diff --git a/application/types.h b/application/types.h index 9692cad..97a72e9 100644 --- a/application/types.h +++ b/application/types.h @@ -136,7 +136,8 @@ struct Attachment { int type; // temp (from table resources) - char *name; + char *nodename; + char *displayname; cxmutstr content; bool content_loaded; -- 2.43.5