Modified gen strings formatting

This commit is contained in:
xavi 2024-09-18 14:15:49 -07:00
parent 20fdead266
commit 4636a19796

View File

@ -37,7 +37,8 @@ int gen_sql_update_stmt_v2(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks*
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET title='%s', due_date='%s' WHERE title='%s' OR active_id='%d'", task->table, task->new_title, task->due_date, task->title, task->active_id);
}
else if (task->new_title != NULL){
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET title='%s' WHERE title='%s' OR active_id='%d'", task->table, task->new_title, task->title, task->active_id);
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET title='%s' WHERE title='%s' OR active_id='%d'",
task->table, task->new_title, task->title, task->active_id);
}
else{
return -1;
@ -58,7 +59,8 @@ int gen_sql_update_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* ta
int rc = 0;
if (task->status != NULL){
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET status='%s' WHERE title='%s' OR active_id='%d'", task->table, task->status, task->title, task->active_id);
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET status='%s' WHERE title='%s' OR active_id='%d'",
task->table, task->status, task->title, task->active_id);
}
else{
snprintf(sql_query, SQLQUERY_MAX, "UPDATE %s SET active_id='NULL',status='complete' WHERE title='%s' OR active_id='%d'", task->table, task->title, task->active_id);
@ -77,7 +79,8 @@ 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'",
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")){
@ -91,7 +94,8 @@ int gen_sql_insert_stmt(sqlite3 *db, sqlite3_stmt** out_stmt, filtered_tasks* ta
char sql_query[SQLQUERY_MAX];
int rc = 0;
snprintf(sql_query, SQLQUERY_MAX, "INSERT INTO %s %s VALUES %s", task->table, task->selected_columns, values);
snprintf(sql_query, SQLQUERY_MAX, "INSERT INTO %s %s VALUES %s",
task->table, task->selected_columns, values);
rc = sqlite3_prepare_v2(db, sql_query, -1, out_stmt, NULL);
if (checksqlerr(rc, "prepare broken in gen_sql_insert_stmt")){
return -1;