]> saetta.ns0.it Git - libgdaex/commitdiff
Wrong hashtable in get_sql_from_hashtable for GDAEX_SQL_DELETE.
authorAndrea Zagli <azagli@libero.it>
Sun, 8 Sep 2019 08:49:36 +0000 (10:49 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 8 Sep 2019 08:49:36 +0000 (10:49 +0200)
src/gdaex.c
tests/getsql.c

index a8e7f79858e270abad342a1079eabf42113a1951..7bf4281f38456d70102ec1240466b0d12a36f942 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  gdaex.c
  *
- *  Copyright (C) 2005-2016 Andrea Zagli <azagli@libero.it>
+ *  Copyright (C) 2005-2019 Andrea Zagli <azagli@libero.it>
  *
  *  This file is part of libgdaex.
  *
@@ -3380,7 +3380,7 @@ const gchar
                                b = gda_sql_builder_new (GDA_SQL_STATEMENT_DELETE);
                                gda_sql_builder_set_table (b, _table_name);
 
-                               if (keys != NULL && g_hash_table_size (fields) > 0)
+                               if (keys != NULL && g_hash_table_size (keys) > 0)
                                        {
                                                g_hash_table_iter_init (&ht_iter_keys, keys);
                                                while (g_hash_table_iter_next (&ht_iter_keys, &key_keys, &value_keys))
index 1e6e04db9edaceda0e7a04e9f00a8407716753f7..083a719585e2a61def6b2ebb62cd70d85db1c76c 100644 (file)
@@ -73,11 +73,12 @@ main (int argc, char **argv)
        g_hash_table_insert (ht_fields, "incoming", gval);
 
        g_message ("%s", gdaex_get_sql_from_hashtable (gdaex, GDAEX_SQL_SELECT, "clients", ht_keys, ht_fields));
-       g_hash_table_destroy (ht_keys);
-       g_hash_table_destroy (ht_fields);
 
        g_message ("%s", gdaex_get_sql_from_hashtable (gdaex, GDAEX_SQL_INSERT, "clients", ht_keys, ht_fields));
 
+       g_hash_table_destroy (ht_keys);
+       g_hash_table_destroy (ht_fields);
+
        ht_keys = g_hash_table_new (g_str_hash, g_str_equal);
        ht_fields = g_hash_table_new (g_str_hash, g_str_equal);
 
@@ -135,7 +136,6 @@ main (int argc, char **argv)
        g_value_set_string (gval, "and this is the new sur'name with '");
        g_hash_table_insert (ht_fields, "surname", gval);
 
-       ht_keys = g_hash_table_new (g_str_hash, g_str_equal);
        gval = g_new0 (GValue, 1);
        g_value_init (gval, G_TYPE_INT);
        g_value_set_int (gval, 55);