]> saetta.ns0.it Git - zakaudit/libzakaudit/commitdiff
Removed field id in table values.
authorAndrea Zagli <azagli@libero.it>
Thu, 2 Sep 2010 07:14:35 +0000 (09:14 +0200)
committerAndrea Zagli <azagli@libero.it>
Thu, 2 Sep 2010 07:14:35 +0000 (09:14 +0200)
ALTER TABLE "values" DROP CONSTRAINT valori_pkey;
ALTER TABLE "values" DROP COLUMN id;
ALTER TABLE "values" ADD PRIMARY KEY (id_actions, id_fields);

src/audit.c

index 748a29ea1811763ce98ac0f5e73008f199fdeb93..d9e9375aef86a3f8686296bb30e9441c20042b1e 100644 (file)
@@ -378,6 +378,7 @@ insert_value (Audit *audit,
               gchar *value)
 {
        gchar *sql;
+       gchar *real_value;
 
        AuditPrivate *priv = AUDIT_GET_PRIVATE (audit);
 
@@ -389,20 +390,6 @@ insert_value (Audit *audit,
                }
        else
                {
-                       /* find the new id */
-                       GdaDataModel *dm;
-                       guint id_new;
-                       gchar *real_value;
-
-                       id_new = 0;
-                       sql = g_strdup_printf ("SELECT COALESCE (MAX (id)) FROM values");
-                       dm = gdaex_query (priv->gdaex, sql);
-                       if (dm != NULL && gda_data_model_get_n_rows (dm) == 1)
-                               {
-                                       id_new = gdaex_data_model_get_value_integer_at (dm, 0, 0);
-                               }
-                       id_new++;
-
                        if (g_strcmp0 (g_utf8_strup (value, -1), "NULL") == 0)
                                {
                                        real_value = g_strdup ("NULL");
@@ -416,9 +403,9 @@ insert_value (Audit *audit,
                                }
 
                        sql = g_strdup_printf ("INSERT INTO values"
-                                              " (id, id_actions, id_fields, value)"
-                                              " VALUES (%d, %d, %d, %s)",
-                                              id_new, id_actions, field->id,
+                                              " (id_actions, id_fields, value)"
+                                              " VALUES (%d, %d, %s)",
+                                              id_actions, field->id,
                                               real_value);
                        gdaex_execute (priv->gdaex, sql);
                }