]> saetta.ns0.it Git - zakaudit/libzakaudit/commitdiff
Error on sql creation on ZakAudit::get_user_insertion when key is multifield.
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 24 Dec 2013 08:13:58 +0000 (09:13 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 24 Dec 2013 08:13:58 +0000 (09:13 +0100)
src/audit.c
tests/test1.c

index d8bcbe7424ab2afa2c04ab349f5d12c9da4a06d6..9e6a523ca95779f9a34405e1c49c5482b7e9a9ad 100644 (file)
@@ -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",
index 4e31a2df3498259652ea5228dec011a11890fc38..2e7d512cb10847976394ad59ba81532e1dee950f 100644 (file)
@@ -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);