Modified delete to only delete active tasks TODO: have way to delete completed tasks
This commit is contained in:
parent
1229d88253
commit
5b5b36c041
@ -5,6 +5,7 @@
|
|||||||
#include "x_curses.h"
|
#include "x_curses.h"
|
||||||
#include "dodo.h"
|
#include "dodo.h"
|
||||||
|
|
||||||
|
//TODO: check that only one row is modified with sqlite3_change()
|
||||||
|
|
||||||
// FOR DEBUG
|
// FOR DEBUG
|
||||||
int callback(void *NotUsed, int argc, char **argv, char **azColName){
|
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];
|
char sql_query[SQLQUERY_MAX];
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
snprintf(sql_query, SQLQUERY_MAX, "DELETE FROM %s WHERE title='%s' OR active_id='%d'",
|
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);
|
||||||
task->table, task->title, task->active_id);
|
|
||||||
|
|
||||||
rc = sqlite3_prepare_v2(db, sql_query, -1, out_stmt, NULL);
|
rc = sqlite3_prepare_v2(db, sql_query, -1, out_stmt, NULL);
|
||||||
if (checksqlerr(rc, "prepare broken in gen_sql_insert_stmt")){
|
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";
|
task->table = "tasks";
|
||||||
|
|
||||||
parse_args(argc, argv, task);
|
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
|
// no v2s allowed
|
||||||
if ( gen_sql_update_stmt_v2(db, &out_stmt, task) ){
|
if ( gen_sql_update_stmt_v2(db, &out_stmt, task) ){
|
||||||
free(task);
|
free(task);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
CREATE TABLE tasks(
|
CREATE TABLE tasks(
|
||||||
task_id INTEGER PRIMARY KEY,
|
task_id INTEGER PRIMARY KEY,
|
||||||
title TEXT NOT NULL UNIQUE,
|
title TEXT NOT NULL,
|
||||||
active_id INTEGER,
|
active_id INTEGER,
|
||||||
status TEXT NOT NULL DEFAULT 'backlog',
|
status TEXT NOT NULL DEFAULT 'backlog',
|
||||||
creation_date DATE DEFAULT (date('now')),
|
creation_date DATE DEFAULT (date('now')),
|
||||||
|
Loading…
Reference in New Issue
Block a user