Modified delete to only delete active tasks TODO: have way to delete completed tasks

This commit is contained in:
xavi 2024-09-20 12:41:21 -07:00
parent 1229d88253
commit 5b5b36c041
2 changed files with 4 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include "x_curses.h"
#include "dodo.h"
//TODO: check that only one row is modified with sqlite3_change()
// FOR DEBUG
int callback(void *NotUsed, int argc, char **argv, char **azColName){
@ -83,8 +84,7 @@ int gen_sql_delete_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* ta
char sql_query[SQLQUERY_MAX];
int rc = 0;
snprintf(sql_query, SQLQUERY_MAX, "DELETE FROM %s WHERE title='%s' OR active_id='%d'",
task->table, task->title, task->active_id);
snprintf(sql_query, SQLQUERY_MAX, "DELETE FROM %s WHERE (title='%s' OR active_id='%d') AND active_id IS NOT NULL", task->table, task->title, task->active_id);
rc = sqlite3_prepare_v2(db, sql_query, -1, out_stmt, NULL);
if (checksqlerr(rc, "prepare broken in gen_sql_insert_stmt")){
@ -484,7 +484,7 @@ int update_task(sqlite3 *db, int argc, char** argv){
task->table = "tasks";
parse_args(argc, argv, task);
// TODO this can definatly be made into one func with all the other updates
// TODO this can definitely be made into one func with all the other updates
// no v2s allowed
if ( gen_sql_update_stmt_v2(db, &out_stmt, task) ){
free(task);

View File

@ -1,6 +1,6 @@
CREATE TABLE tasks(
task_id INTEGER PRIMARY KEY,
title TEXT NOT NULL UNIQUE,
title TEXT NOT NULL,
active_id INTEGER,
status TEXT NOT NULL DEFAULT 'backlog',
creation_date DATE DEFAULT (date('now')),