From 7cfc5f3a029ce8aa1bdb9cff882dfeab39374547 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 15 May 2025 12:46:02 +0200 Subject: [PATCH] SQL formatting --- application/store.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/application/store.c b/application/store.c index 5a963b1..48c18be 100644 --- a/application/store.c +++ b/application/store.c @@ -56,11 +56,16 @@ "select * from cols\n" \ "order by path;" -#define SQL_NOTEBOOK_GET_NOTES "select n.*, r.resource_id as [__resources__resource_id], r.parent_id, r.nodename, r.displayname, r.lastmodified, r.creationdate, r.iscollection, r.contenttype from resources r inner join notes n on r.resource_id = n.resource_id where parent_id = ? ;" +#define SQL_NOTEBOOK_GET_NOTES \ + "select n.*, r.resource_id as [__resources__resource_id], r.parent_id, " \ + "r.nodename, r.displayname, r.lastmodified, r.creationdate, r.iscollection, r.contenttype " \ + "from resources r inner join notes n on r.resource_id = n.resource_id where parent_id = ? ;" #define SQL_NOTE_GET_CONTENT "select content from resources where resource_id = ? ;" -#define SQL_NOTE_RESOURCE_NEW "insert into resources(parent_id, nodename, displayname, lastmodified, creationdate, content) values (?, ?, ?, unixepoch(), unixepoch(), ?) returning resource_id;" +#define SQL_NOTE_RESOURCE_NEW \ + "insert into resources(parent_id, nodename, displayname, lastmodified, creationdate, content) values " \ + "(?, ?, ?, unixepoch(), unixepoch(), ?) returning resource_id;" #define SQL_NOTE_NEW "insert into notes(resource_id, type) values (?, ?) returning note_id;" @@ -74,15 +79,22 @@ #define SQL_NOTE_DELETE "delete from resources where resource_id = ? ;" -#define SQL_ATTACHMENT_RESOURCE_NEW "insert into resources(parent_id, nodename, lastmodified, creationdate, content) values ((select parent_id from resources where resource_id = ?), ?, unixepoch(), unixepoch(), ?) returning resource_id;" -#define SQL_ATTACHMENT_NEW "insert into attachments(attachment_resource_id, parent_resource_id, type) values (?, ?, ?) returning attachment_id;" +#define SQL_ATTACHMENT_RESOURCE_NEW \ + "insert into resources(parent_id, nodename, lastmodified, creationdate, content) values " \ + "((select parent_id from resources where resource_id = ?), ?, unixepoch(), unixepoch(), ?) returning resource_id;" + +#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.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;" -#define SQL_NOTEBOOK_NEW "insert into resources(parent_id, nodename, iscollection) values (?, ?, 1) returning resource_id;" +#define SQL_NOTEBOOK_NEW \ + "insert into resources(parent_id, nodename, iscollection) values " \ + "(?, ?, 1) returning resource_id;" static DBUConnection *connection; -- 2.43.5