From 479944e54640d35053b6b27e541df8dc9c366fdd Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 13 Jan 2026 20:26:10 +0100 Subject: [PATCH] create groups in the notebook structure as normal notebooks --- application/store.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/application/store.c b/application/store.c index a521e16..a90342d 100644 --- a/application/store.c +++ b/application/store.c @@ -107,7 +107,7 @@ "update resources set nodename = ?, displayname = ?, contenttype = ? where resource_id = ? ;" #define SQL_NOTEBOOK_NEW \ - "insert into notebooks(resource_id, position) " \ + "insert into notebooks(resource_id, position) values " \ "(?, (select coalesce(max(position), 0)+1 from notebooks)) returning notebook_id;" #define SQL_NOTEBOOK_SWAP_POS \ @@ -353,16 +353,29 @@ int note_store_create_default(const char *host, const char *user) { dbuQuerySetParamInt64(q, 1, collection_id); if(!q->exec(q)) { err = dbuResultAsValue(q->getResult(q), ¬ebooks_id); + if(!err) { + DBUResult *result = dbuSqlExecParamInt64(connection, NULL, SQL_NOTEBOOK_NEW, notebooks_id); + int64_t unused; + err = dbuResultAsInt64(result, &unused); + } } dbuQueryFree(q); - q = connection->createQuery(connection, NULL); - dbuQuerySetSQL(q, "insert into resources(parent_id, nodename, iscollection) values (?, 'My Notes', 1) returning resource_id;"); - dbuQuerySetParamInt64(q, 1, notebooks_id); - if(!q->exec(q)) { - err = dbuResultAsValue(q->getResult(q), &mynotes_id); + if(!err) { + q = connection->createQuery(connection, NULL); + dbuQuerySetSQL(q, "insert into resources(parent_id, nodename, iscollection) values (?, 'My Notes', 1) returning resource_id;"); + dbuQuerySetParamInt64(q, 1, notebooks_id); + if(!q->exec(q)) { + err = dbuResultAsValue(q->getResult(q), &mynotes_id); + if(!err) { + DBUResult *result = dbuSqlExecParamInt64(connection, NULL, SQL_NOTEBOOK_NEW, mynotes_id); + int64_t unused; + err = dbuResultAsInt64(result, &unused); + } + } + dbuQueryFree(q); } - dbuQueryFree(q); + return err; } -- 2.47.3