]> uap-core.de Git - note.git/commitdiff
create groups in the notebook structure as normal notebooks
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 13 Jan 2026 19:26:10 +0000 (20:26 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 13 Jan 2026 19:26:10 +0000 (20:26 +0100)
application/store.c

index a521e16c1ea408a0e6db568c3257ba808ce2fcb7..a90342d09f413a1408bcb7a21aa3c9f085c715b8 100644 (file)
     "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), &notebooks_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;
 }