]> uap-core.de Git - note.git/commitdiff
fix wrong column name in attachment sql query
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Wed, 7 May 2025 20:20:50 +0000 (22:20 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Wed, 7 May 2025 20:20:50 +0000 (22:20 +0200)
application/attachment.c
application/gtk-text.c
application/note.c
application/store.c
application/types.c
application/types.h

index c5cf9ba7fd1c032722548bc697c9f063117978cc..f222c212556223701e5a7cb9ccae1b299ebd63d6 100644 (file)
@@ -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;
 }
index cd896fd1f2fba1523ea7cacfebed83d57dee005a..9cc5de18238d907138c60c4aee6eb3d199fe4805 100644 (file)
@@ -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);
 }
index e19cd270919ce9882747e215276e8a27663ce456..06ff6a3d437265c95b48e9ee47189f5465c2acfc 100644 (file)
@@ -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;
         }
     }
index 8d9b392afa0bee70c6ba24e3d12a4be4edaeca8a..2c82211ca26044d601a9daa93da0bca36bd13c37 100644 (file)
@@ -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;
index 57db2a7cbfdf0668a13c5b7a7af32119f2311e35..f0f53414ba4486030b83c53796a871a885254ac4 100644 (file)
@@ -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);
 }
index 9692cad6c77ebdf3164d7862e11876e1df63816a..97a72e9177d3f43fe7f164592f75057db434ccb1 100644 (file)
@@ -136,7 +136,8 @@ struct Attachment {
     int        type;
     
     // temp (from table resources)
-    char       *name;
+    char       *nodename;
+    char       *displayname;
     cxmutstr   content;
     bool       content_loaded;