[libgda] More GDA_TYPE_NULL corrections, for gda_g_type_from_string()
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] More GDA_TYPE_NULL corrections, for gda_g_type_from_string()
- Date: Thu, 30 Jun 2011 18:59:00 +0000 (UTC)
commit 2efce9aa794346eabd7a005ff1183bd6b43e5027
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Jun 30 20:58:49 2011 +0200
More GDA_TYPE_NULL corrections, for gda_g_type_from_string()
doc/C/migration3.xml | 3 +++
libgda/gda-data-model-import.c | 4 ++++
libgda/gda-meta-store.c | 2 ++
libgda/gda-meta-struct-io.c | 2 ++
libgda/gda-meta-struct.c | 2 ++
libgda/gda-server-operation.c | 7 +++++--
libgda/gda-set.c | 7 +++++--
libgda/gda-value.c | 8 +++++---
libgda/handlers/gda-handler-type.c | 14 +++++++++-----
libgda/sql-parser/gda-statement-struct-pspec.c | 4 ++++
libgda/sqlite/virtual/gda-vconnection-hub.c | 2 ++
providers/ldap/gda-ldap-util.c | 4 ++--
providers/web/gda-web-recordset.c | 2 ++
13 files changed, 47 insertions(+), 14 deletions(-)
---
diff --git a/doc/C/migration3.xml b/doc/C/migration3.xml
index a74cf9c..6fbe494 100644
--- a/doc/C/migration3.xml
+++ b/doc/C/migration3.xml
@@ -25,6 +25,9 @@
<listitem><para>if you used <link linkend="g-value-init">g_value_init()</link> on a
value of type GDA_TYPE_NULL, then you'll have to eight clear the value first, or replace
that call with a call to <link linkend="gda-value-reset-with-type">gda_value_reset_with_type()</link></para></listitem>
+ <listitem><para>the <link linkend="gda-g-type-from-string">gda_g_type_from_string()</link> function
+ now returns G_TYPE_INVALID if it does not know how to interpret the argument, so testing the return
+ value now also involves testing for the G_TYPE_INVALID value.</para></listitem>
<listitem><para>creating a GValue using <link linkend="g-new0">g_new0()</link> resulted
in a GDA_TYPE_NULL value, which is not longer the case; the value needs to be initialized
with a call to <link linkend="g-value-init">g_value_init()</link></para></listitem>
diff --git a/libgda/gda-data-model-import.c b/libgda/gda-data-model-import.c
index 4ca4ed6..d50378f 100644
--- a/libgda/gda-data-model-import.c
+++ b/libgda/gda-data-model-import.c
@@ -1261,6 +1261,8 @@ init_xml_import (GdaDataModelImport *model)
if (str) {
spec->gdatype = gda_g_type_from_string (str);
xmlFree (str);
+ if (spec->gdatype == G_TYPE_INVALID)
+ spec->gdatype = GDA_TYPE_NULL;
}
else {
add_error (model, _("No \"gdatype\" attribute specified in <gda_array_field>"));
@@ -1584,6 +1586,8 @@ init_node_import (GdaDataModelImport *model)
if (str) {
spec->gdatype = gda_g_type_from_string (str);
xmlFree (str);
+ if (spec->gdatype == G_TYPE_INVALID)
+ spec->gdatype = GDA_TYPE_NULL;
}
else {
add_error (model, _("No \"gdatype\" attribute specified in <gda_array_field>"));
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index c0b6452..d36f736 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -1487,6 +1487,8 @@ create_table_object (GdaMetaStoreClass *klass, GdaMetaStore *store, xmlNodePtr n
GdaSqlParamSpec *pspec = g_new0 (GdaSqlParamSpec, 1);
GdaSqlExpr *expr;
ptype = ctype ? gda_g_type_from_string ((gchar *) ctype) : G_TYPE_STRING;
+ if (ptype == G_TYPE_INVALID)
+ ptype = GDA_TYPE_NULL;
pspec->name = g_strdup_printf ("+%d", colindex);
pspec->g_type = ptype;
pspec->nullok = nullok;
diff --git a/libgda/gda-meta-struct-io.c b/libgda/gda-meta-struct-io.c
index ba2c376..528335a 100644
--- a/libgda/gda-meta-struct-io.c
+++ b/libgda/gda-meta-struct-io.c
@@ -259,6 +259,8 @@ create_table_object (GdaMetaStruct *mstruct, const GValue *catalog, const gchar
tcol->gtype = ctype ? gda_g_type_from_string ((gchar *) ctype) : G_TYPE_STRING;
if (ctype)
xmlFree (ctype);
+ if (tcol->gtype == G_TYPE_INVALID)
+ tcol->gtype = GDA_TYPE_NULL;
tcol->pkey = pkey;
tcol->nullok = nullok;
if (pkey)
diff --git a/libgda/gda-meta-struct.c b/libgda/gda-meta-struct.c
index 174cb2a..6f53360 100644
--- a/libgda/gda-meta-struct.c
+++ b/libgda/gda-meta-struct.c
@@ -997,6 +997,8 @@ _meta_struct_complement (GdaMetaStruct *mstruct, GdaMetaDbObjectType type,
cvalue = gda_data_model_get_value_at (model, 2, i, error);
if (!cvalue) goto onerror;
tcol->gtype = gda_g_type_from_string (g_value_get_string (cvalue));
+ if (tcol->gtype == G_TYPE_INVALID)
+ tcol->gtype = GDA_TYPE_NULL;
cvalue = gda_data_model_get_value_at (model, 3, i, error);
if (!cvalue) goto onerror;
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index f49f48f..6c4c734 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -943,12 +943,15 @@ load_xml_spec (GdaServerOperation *op, xmlNodePtr specnode, const gchar *root, G
else if (!strcmp ((gchar*)node->name, "parameter")) {
GdaHolder *param = NULL;
xmlChar *gdatype;
+ GType gt;
/* find data type and create GdaHolder */
gdatype = xmlGetProp (node, BAD_CAST "gdatype");
+ gt = gdatype ? gda_g_type_from_string ((gchar*) gdatype) : G_TYPE_STRING;
+ if (gt == G_TYPE_INVALID)
+ gt = GDA_TYPE_NULL;
param = GDA_HOLDER (g_object_new (GDA_TYPE_HOLDER,
- "g-type",
- gdatype ? gda_g_type_from_string ((gchar*) gdatype) : G_TYPE_STRING,
+ "g-type", gt,
NULL));
if (gdatype)
xmlFree (gdatype);
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 8c2a7be..547b0a9 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -904,9 +904,12 @@ gda_set_new_from_spec_node (xmlNodePtr xml_spec, GError **error)
gdatype = xmlGetProp (cur, BAD_CAST "gdatype");
if (!holder) {
+ GType gt;
+ gt = gdatype ? gda_g_type_from_string ((gchar *) gdatype) : G_TYPE_STRING;
+ if (gt == G_TYPE_INVALID)
+ gt = GDA_TYPE_NULL;
holder = (GdaHolder*) (g_object_new (GDA_TYPE_HOLDER,
- "g-type",
- gdatype ? gda_g_type_from_string ((gchar *) gdatype) : G_TYPE_STRING,
+ "g-type", gt,
NULL));
holders = g_slist_append (holders, holder);
}
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 5a1fdb8..107098a 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -205,8 +205,10 @@ set_from_string (GValue *value, const gchar *as_string)
retval = TRUE;
}
else if (type == G_TYPE_GTYPE) {
- if (gda_g_type_from_string (as_string) != 0) {
- g_value_set_gtype (value, gda_g_type_from_string (as_string));
+ GType gt;
+ gt = gda_g_type_from_string (as_string);
+ if (gt != G_TYPE_INVALID) {
+ g_value_set_gtype (value, gt);
retval = TRUE;
}
}
@@ -1330,7 +1332,7 @@ gda_value_new_from_xml (const xmlNodePtr node)
return NULL;
value = g_new0 (GValue, 1);
- prop = xmlGetProp (node, (xmlChar*)"gdatype");
+ prop = xmlGetProp (node, (xmlChar*) "gdatype");
if (prop && !gda_value_set_from_string (value,
(gchar*)xmlNodeGetContent (node),
gda_g_type_from_string ((gchar*) prop))) {
diff --git a/libgda/handlers/gda-handler-type.c b/libgda/handlers/gda-handler-type.c
index 9898737..d1b1b99 100644
--- a/libgda/handlers/gda-handler-type.c
+++ b/libgda/handlers/gda-handler-type.c
@@ -234,8 +234,10 @@ gda_handler_type_get_value_from_sql (GdaDataHandler *iface, const gchar *sql, G_
str[i-1] = 0;
type = gda_g_type_from_string (str+1);
g_free (str);
- value = g_value_init (g_new0 (GValue, 1), G_TYPE_GTYPE);
- g_value_set_gtype (value, type);
+ if (type != G_TYPE_INVALID) {
+ value = g_value_init (g_new0 (GValue, 1), G_TYPE_GTYPE);
+ g_value_set_gtype (value, type);
+ }
}
}
else
@@ -247,7 +249,7 @@ static GValue *
gda_handler_type_get_value_from_str (GdaDataHandler *iface, const gchar *str, G_GNUC_UNUSED GType type)
{
GdaHandlerType *hdl;
- GValue *value;
+ GValue *value = NULL;
GType vtype;
g_return_val_if_fail (iface && GDA_IS_HANDLER_TYPE (iface), NULL);
@@ -255,8 +257,10 @@ gda_handler_type_get_value_from_str (GdaDataHandler *iface, const gchar *str, G_
g_return_val_if_fail (hdl->priv, NULL);
vtype = gda_g_type_from_string (str);
- value = g_value_init (g_new0 (GValue, 1), G_TYPE_GTYPE);
- g_value_set_gtype (value, vtype);
+ if (vtype != G_TYPE_INVALID) {
+ value = g_value_init (g_new0 (GValue, 1), G_TYPE_GTYPE);
+ g_value_set_gtype (value, vtype);
+ }
return value;
}
diff --git a/libgda/sql-parser/gda-statement-struct-pspec.c b/libgda/sql-parser/gda-statement-struct-pspec.c
index 04b6f98..9733561 100644
--- a/libgda/sql-parser/gda-statement-struct-pspec.c
+++ b/libgda/sql-parser/gda-statement-struct-pspec.c
@@ -113,6 +113,8 @@ gda_sql_param_spec_take_type (GdaSqlParamSpec *pspec, GValue *value)
pspec->g_type = gda_g_type_from_string (tmp);
g_free (tmp);
+ if (pspec->g_type == G_TYPE_INVALID)
+ pspec->g_type = GDA_TYPE_NULL;
}
}
@@ -154,6 +156,8 @@ gda_sql_param_spec_new (GValue *value)
break;
case 1:
pspec->g_type = gda_g_type_from_string (str);
+ if (pspec->g_type == G_TYPE_INVALID)
+ pspec->g_type = GDA_TYPE_NULL;
break;
case 2:
pspec->nullok = (*str == 'n') || (*str == 'N') ? TRUE : FALSE;
diff --git a/libgda/sqlite/virtual/gda-vconnection-hub.c b/libgda/sqlite/virtual/gda-vconnection-hub.c
index eeb518b..adade51 100644
--- a/libgda/sqlite/virtual/gda-vconnection-hub.c
+++ b/libgda/sqlite/virtual/gda-vconnection-hub.c
@@ -352,6 +352,8 @@ compute_column_specs (GdaVconnectionDataModelSpec *spec)
lspec->col_names[i] = g_value_dup_string (v0);
lspec->col_gtypes[i] = gda_g_type_from_string (g_value_get_string (v2));
+ if (lspec->col_gtypes[i] == G_TYPE_INVALID)
+ lspec->col_gtypes[i] = GDA_TYPE_NULL;
lspec->col_dtypes[i] = g_value_dup_string (v1);
}
g_object_unref (model);
diff --git a/providers/ldap/gda-ldap-util.c b/providers/ldap/gda-ldap-util.c
index c836e4e..47b2230 100644
--- a/providers/ldap/gda-ldap-util.c
+++ b/providers/ldap/gda-ldap-util.c
@@ -816,13 +816,13 @@ gda_ldap_get_g_type (LdapConnectionData *cdata, const gchar *attribute_name, con
GType coltype = GDA_TYPE_NULL;
if (specified_gtype)
coltype = gda_g_type_from_string (specified_gtype);
- if (coltype == GDA_TYPE_NULL) {
+ if ((coltype == G_TYPE_INVALID) || (coltype == GDA_TYPE_NULL)) {
LdapAttribute *lat;
lat = gda_ldap_get_attr_info (cdata, attribute_name);
if (lat)
coltype = lat->type->gtype;
}
- if (coltype == GDA_TYPE_NULL)
+ if ((coltype == G_TYPE_INVALID) || (coltype == GDA_TYPE_NULL))
coltype = G_TYPE_STRING;
return coltype;
}
diff --git a/providers/web/gda-web-recordset.c b/providers/web/gda-web-recordset.c
index 046db82..c4be75c 100644
--- a/providers/web/gda-web-recordset.c
+++ b/providers/web/gda-web-recordset.c
@@ -266,6 +266,8 @@ gda_web_recordset_new (GdaConnection *cnc, GdaWebPStmt *ps, GdaSet *exec_params,
GType type;
type = gda_g_type_from_string ((gchar*) prop);
+ if (type == G_TYPE_INVALID)
+ type = GDA_TYPE_NULL;
_GDA_PSTMT (ps)->types [i] = type;
gda_column_set_g_type (column, type);
xmlFree (prop);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]