From: Andrea Zagli Date: Tue, 24 Dec 2013 08:13:58 +0000 (+0100) Subject: Error on sql creation on ZakAudit::get_user_insertion when key is multifield. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=476d04d106dcb058e8af50136434884e8710090e;p=zakaudit%2Flibzakaudit Error on sql creation on ZakAudit::get_user_insertion when key is multifield. --- diff --git a/src/audit.c b/src/audit.c index d8bcbe7..9e6a523 100644 --- a/src/audit.c +++ b/src/audit.c @@ -1412,7 +1412,7 @@ GtkWidget g_object_unref (dm); } - lstore = GTK_TREE_STORE (gtk_list_store_newv (4 + rows, gtype)); + lstore = GTK_LIST_STORE (gtk_list_store_newv (4 + rows, gtype)); gtk_tree_view_set_model (tview, GTK_TREE_MODEL (lstore)); /* find the last action @@ -1437,7 +1437,7 @@ GtkWidget { gtk_list_store_append (lstore, &iter); gtk_list_store_set (lstore, &iter, - COL_CHANGES_ID, gdaex_data_model_get_value_integer_at (dm, 0, "id"), + COL_CHANGES_ID, gdaex_data_model_get_field_value_integer_at (dm, 0, "id"), COL_CHANGES_DATE, g_date_time_format (gdaex_data_model_get_field_value_gdatetime_at (dm, 0, "date"), "%d/%m/%Y %H.%M.%S"), COL_CHANGES_OPERATION, gdaex_data_model_get_field_value_integer_at (dm, 0, "type") == ZAK_AUDIT_ACTION_DELETE ? "Delete" : gdaex_data_model_get_field_value_integer_at (dm, 0, "type") == ZAK_AUDIT_ACTION_AFTER_UPDATE ? "Edit" : @@ -1574,16 +1574,17 @@ const gchar if (field_value == NULL) break; /* TODO the db field can be other type than string */ - g_string_append_printf (sql_where, " AND v.id_fields = %d" - " AND v.value = '%s'", + g_string_append_printf (sql_where, + " AND EXISTS (SELECT v.id_actions" + " FROM values AS v WHERE a.id = v.id_actions" + " AND v.id_fields = %d" + " AND v.value = '%s')", field->id, - field_value, field_value); } sql = g_strdup_printf ("SELECT a.username" " FROM actions AS a" - " INNER JOIN values AS v ON a.id = v.id_actions" " WHERE a.type = %d" " AND a.id_tables = %d" "%s", diff --git a/tests/test1.c b/tests/test1.c index 4e31a2d..2e7d512 100644 --- a/tests/test1.c +++ b/tests/test1.c @@ -108,7 +108,7 @@ main (int argc, char *argv[]) return 0; } gda_connection_statement_execute_non_select (conn, stmt, NULL, NULL, NULL); - zak_audit_action_from_gdastatement (audit, ZAK_AUDIT_ACTION_INSERT, "I", "audit_test1", stmt); + zak_audit_action_from_gdastatement (audit, ZAK_AUDIT_ACTION_INSERT, "Y", "audit_test1", stmt); stmt = gda_sql_parser_parse_string (parser, "UPDATE test1 SET income=99999999.99 WHERE id = 2", NULL, NULL); if (stmt == NULL) @@ -130,7 +130,7 @@ main (int argc, char *argv[]) gda_connection_statement_execute_non_select (conn, stmt, NULL, NULL, NULL); g_warning ("User insertion: %s", - zak_audit_get_user_insertion (audit, "audit_test1", "test1", g_strsplit ("id|2", "|", -1))); + zak_audit_get_user_insertion (audit, "audit_test1", "test1", (const gchar **)g_strsplit ("id|2", "|", -1))); zak_audit_destroy (audit);