Compare commits

..

No commits in common. "76fb74d504d00b10902344f5f7e9232e56be1edd" and "09492950b8bc07f188d2b871789595fdb0ee24a7" have entirely different histories.

2 changed files with 3 additions and 30 deletions

View File

@ -76,12 +76,7 @@ int gen_sql_update_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, char* table, char*
char sql_query[SQLQUERY_MAX];
int rc = 0;
if (status != NULL){
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET status='%s' WHERE title='%s'", table, status, title);
}
else{
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET active_id='NULL',status='complete' WHERE title='%s'", table, title);
}
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET status='%s' WHERE title='%s'", table, status, title);
rc = sqlite3_prepare_v2(db, sql_query, -1, out_stmt, NULL);
@ -125,7 +120,7 @@ int gen_sql_select_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, char* colnames, ch
char sql_query[SQLQUERY_MAX];
int rc = 0;
snprintf(sql_query, SQLQUERY_MAX, "SELECT %s FROM %s WHERE status='%s' AND active_id!='NULL'", colnames, table, status);
snprintf(sql_query, SQLQUERY_MAX, "SELECT %s FROM %s WHERE status='%s'", colnames, table, status);
rc = sqlite3_prepare_v2(db, sql_query, -1, out_stmt, NULL);
if (checksqlerr(rc, "prepare broken in gen_sql_select_stmt")){
return -1;
@ -235,25 +230,6 @@ int parse_args(int argc, char** argv, char** title, char** due_date){
}
int complete_task(sqlite3 *db, int argc, char** argv){
int rc = 0;
char* table = "tasks";
char* title;
sqlite3_stmt* out_stmt;
parse_args(argc, argv, &title, NULL);
if ( gen_sql_update_stmt(db, &out_stmt, table, NULL, title) ){
return -1;
}
if ( ( rc = sqlite3_step(out_stmt) ) == SQLITE_DONE){
return 0;
}
checksqlerr(rc, "broken in complete_task");
return 1;
}
int update_task_status(sqlite3 *db, int argc, char** argv){
int rc = 0;
char* table = "tasks";
@ -381,9 +357,6 @@ int main( int argc, char **argv ){
else if (x_strcmp(argv[1], "backlog") == 0){
rc = update_task_status(db,argc,argv);
}
else if (x_strcmp(argv[1], "done") == 0){
rc = complete_task(db,argc,argv);
}
else if (x_strcmp(argv[1], "view_all") == 0){
rc = view_all(db);
}

View File

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