[libgda/LIBGDA_4.0] Correctly name GdaHolder in a GdaDataModelIter, fixes bug #601333
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.0] Correctly name GdaHolder in a GdaDataModelIter, fixes bug #601333
- Date: Thu, 12 Nov 2009 19:56:10 +0000 (UTC)
commit ff3aa2a4cb83214a278030866521529d2adc157b
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Nov 12 20:49:41 2009 +0100
Correctly name GdaHolder in a GdaDataModelIter, fixes bug #601333
fixes a bug which has been introduced with commit
bbd8af19795aaa610301e25dda601a92dd124f83
libgda/gda-data-model-iter.c | 34 ++++++++++++++++++++++++++++++----
tests/data-models/check_pmodel.c | 2 +-
2 files changed, 31 insertions(+), 5 deletions(-)
---
diff --git a/libgda/gda-data-model-iter.c b/libgda/gda-data-model-iter.c
index 09f5a80..82a3bf1 100644
--- a/libgda/gda-data-model-iter.c
+++ b/libgda/gda-data-model-iter.c
@@ -436,11 +436,37 @@ gda_data_model_iter_set_property (GObject *object,
g_free (str);
}
else {
- gchar *tmp = g_strdup_printf ("col%d", col);
- g_object_set (G_OBJECT (param), "id", tmp, NULL);
- g_free (tmp);
-
const gchar *cstr;
+ gchar *tmp;
+
+ /* ID attribute */
+ cstr = gda_column_get_description (column);
+ if (!cstr)
+ cstr = gda_column_get_name (column);
+ if (cstr)
+ tmp = (gchar *) cstr;
+ else
+ tmp = g_strdup_printf ("col%d", col);
+
+ if (gda_set_get_holder ((GdaSet *) iter, tmp)) {
+ gint e;
+ for (e = 1; ; e++) {
+ gchar *tmp2 = g_strdup_printf ("%s_%d", tmp, e);
+ if (! gda_set_get_holder ((GdaSet *) iter, tmp2)) {
+ g_object_set (G_OBJECT (param), "id", tmp2, NULL);
+ g_free (tmp2);
+ break;
+ }
+ g_free (tmp2);
+ }
+ }
+ else
+ g_object_set (G_OBJECT (param), "id", tmp, NULL);
+
+ if (!cstr)
+ g_free (tmp);
+
+ /* other attributes */
cstr = gda_column_get_description (column);
if (cstr)
g_object_set (G_OBJECT (param), "description", cstr, NULL);
diff --git a/tests/data-models/check_pmodel.c b/tests/data-models/check_pmodel.c
index aa22efb..86c2e03 100644
--- a/tests/data-models/check_pmodel.c
+++ b/tests/data-models/check_pmodel.c
@@ -1293,7 +1293,7 @@ test12 (GdaConnection *cnc)
}
g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "Nick");
- if (! gda_set_set_holder_value (GDA_SET (iter), &error, "col1", "Nick")) {
+ if (! gda_set_set_holder_value (GDA_SET (iter), &error, "name", "Nick")) {
nfailed++;
#ifdef CHECK_EXTRA_INFO
g_print ("GdaDataModelIter value set failed: %s\n",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]