From b032c3f690c7e2cc2a3754b4c7458432060e8e97 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Sun, 11 Jan 2026 12:18:31 +0000 Subject: [PATCH] Fix boolean literal handling in SET command for MCP variables When SET commands use boolean literals (true/false), SQLite was interpreting them as boolean keywords and storing 1/0 instead of the string values "true"/"false". Fixed by detecting boolean literals in admin_handler_command_set() and quoting them as strings in the UPDATE statement. All 52 MCP module TAP tests now pass. --- lib/Admin_Handler.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Admin_Handler.cpp b/lib/Admin_Handler.cpp index 159ab10d7..5bf94247c 100644 --- a/lib/Admin_Handler.cpp +++ b/lib/Admin_Handler.cpp @@ -941,7 +941,15 @@ bool admin_handler_command_set(char *query_no_space, unsigned int query_no_space free(buff); run_query = false; } else { - const char *update_format = (char *)"UPDATE global_variables SET variable_value=%s WHERE variable_name='%s'"; + // Check if the value is a boolean literal that needs to be quoted as a string + // to prevent SQLite from interpreting it as a boolean keyword (storing 1 or 0) + bool is_boolean = (strcasecmp(var_value, "true") == 0 || strcasecmp(var_value, "false") == 0); + const char *update_format; + if (is_boolean) { + update_format = (char *)"UPDATE global_variables SET variable_value='%s' WHERE variable_name='%s'"; + } else { + update_format = (char *)"UPDATE global_variables SET variable_value=%s WHERE variable_name='%s'"; + } // Computed length is more than needed since it also counts the format modifiers (%s). size_t query_len = strlen(update_format) + strlen(var_name) + strlen(var_value) + 1; char *query = (char *)l_alloc(query_len);