From dab84cb75d41d9febce41a927cd28a748b3bdee6 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 2 Sep 2010 09:14:35 +0200 Subject: [PATCH] Removed field id in table values. 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 | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/audit.c b/src/audit.c index 748a29e..d9e9375 100644 --- a/src/audit.c +++ b/src/audit.c @@ -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); } -- 2.49.0