From: Andrea Zagli Date: Sun, 8 Sep 2019 08:49:36 +0000 (+0200) Subject: Wrong hashtable in get_sql_from_hashtable for GDAEX_SQL_DELETE. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=5bb976de82b27e1f2c486ff7b9b026a700387c31;p=libgdaex Wrong hashtable in get_sql_from_hashtable for GDAEX_SQL_DELETE. --- diff --git a/src/gdaex.c b/src/gdaex.c index a8e7f79..7bf4281 100644 --- a/src/gdaex.c +++ b/src/gdaex.c @@ -1,7 +1,7 @@ /* * gdaex.c * - * Copyright (C) 2005-2016 Andrea Zagli + * Copyright (C) 2005-2019 Andrea Zagli * * 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)) diff --git a/tests/getsql.c b/tests/getsql.c index 1e6e04d..083a719 100644 --- a/tests/getsql.c +++ b/tests/getsql.c @@ -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);