[libgda] More "GDA_TYPE_NULL is not 0 anymore" work, for bug #652702



commit 59d355dd023a2ef328b8d5f53bc0b519c6e7eef7
Author: Vivien Malerba <malerba gnome-db org>
Date:   Thu Jun 16 19:28:50 2011 +0200

    More "GDA_TYPE_NULL is not 0 anymore" work, for bug #652702

 libgda-report/engine/gda-report-engine.c    |    2 +-
 libgda-ui/data-entries/gdaui-entry-none.c   |    2 --
 libgda/gda-data-model.c                     |    7 +++----
 providers/mysql/gda-mysql-recordset.c       |    4 ++--
 providers/postgres/gda-postgres-recordset.c |    2 +-
 5 files changed, 7 insertions(+), 10 deletions(-)
---
diff --git a/libgda-report/engine/gda-report-engine.c b/libgda-report/engine/gda-report-engine.c
index 3bf6baf..32879bd 100644
--- a/libgda-report/engine/gda-report-engine.c
+++ b/libgda-report/engine/gda-report-engine.c
@@ -962,7 +962,7 @@ rewrite_statement_foreach_func (GdaSqlAnyPart *node, ForeachData *fdata, GError
 
 	if ((node->type == GDA_SQL_ANY_EXPR) &&
 	    (pspec = ((GdaSqlExpr*) node)->param_spec)) {
-		if (pspec->g_type != 0)
+		if (pspec->g_type != GDA_TYPE_NULL)
 			return TRUE;
 
 		GdaHolder *source_param;
diff --git a/libgda-ui/data-entries/gdaui-entry-none.c b/libgda-ui/data-entries/gdaui-entry-none.c
index 490753d..f7b7ac5 100644
--- a/libgda-ui/data-entries/gdaui-entry-none.c
+++ b/libgda-ui/data-entries/gdaui-entry-none.c
@@ -110,8 +110,6 @@ gdaui_entry_none_new (GType type)
 	GObject *obj;
 	GdauiEntryNone *entry;
 
-	g_return_val_if_fail (type != GDA_TYPE_NULL , NULL);
-
 	obj = g_object_new (GDAUI_TYPE_ENTRY_NONE, NULL);
 	entry = GDAUI_ENTRY_NONE (obj);
 	gdaui_data_entry_set_value_type (GDAUI_DATA_ENTRY (entry), type);
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index bc4b1b2..72a9404 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -1856,9 +1856,8 @@ gda_data_model_import_from_model (GdaDataModel *to, GdaDataModel *from,
 
 		column = gda_data_model_describe_column (to, i);
 		if (plist->data) {
-			if ((gda_holder_get_g_type (GDA_HOLDER (plist->data)) != 
-			     gda_column_get_g_type (column)) &&
-			    (gda_column_get_g_type (column) != G_TYPE_INVALID)) {
+			if ((gda_holder_get_g_type (GDA_HOLDER (plist->data)) != gda_column_get_g_type (column)) &&
+			    (gda_column_get_g_type (column) != GDA_TYPE_NULL)) {
 				GValue *newval;
 				
 				newval = g_new0 (GValue, 1);
@@ -1911,7 +1910,7 @@ gda_data_model_import_from_model (GdaDataModel *to, GdaDataModel *from,
 				value = (GValue *) gda_holder_get_value (GDA_HOLDER (plist->data));
 				if (avlist->data) {
 					if (append_types [i] && gda_value_is_null ((GValue *) (avlist->data))) 
-						g_value_init ((GValue *) (avlist->data), append_types [i]);
+						gda_value_reset_with_type ((GValue *) (avlist->data), append_types [i]);
 					if (!gda_value_is_null (value) && 
 					    !g_value_transform (value, (GValue *) (avlist->data))) {
 						gchar *str;
diff --git a/providers/mysql/gda-mysql-recordset.c b/providers/mysql/gda-mysql-recordset.c
index 4cd4708..83a66a5 100644
--- a/providers/mysql/gda-mysql-recordset.c
+++ b/providers/mysql/gda-mysql-recordset.c
@@ -462,7 +462,7 @@ gda_mysql_recordset_new_direct (GdaConnection *cnc, GdaDataModelAccessFlags flag
 		MYSQL_FIELD *field = &mysql_fields[i];
 		
 		GType gtype = model->priv->types [i];
-		if (gtype == 0) {
+		if (gtype == GDA_TYPE_NULL) {
 			gtype = _gda_mysql_type_to_gda (cdata, field->type, field->charsetnr);
 			model->priv->types [i] = gtype;
 		}
@@ -609,7 +609,7 @@ gda_mysql_recordset_new (GdaConnection            *cnc,
 		MYSQL_FIELD *field = &mysql_fields[i];
 		
 		GType gtype = _GDA_PSTMT(ps)->types[i];
-		if (gtype == 0) {
+		if (gtype == GDA_TYPE_NULL) {
 			gtype = _gda_mysql_type_to_gda (cdata, field->type, field->charsetnr);
 			_GDA_PSTMT(ps)->types[i] = gtype;
 		}
diff --git a/providers/postgres/gda-postgres-recordset.c b/providers/postgres/gda-postgres-recordset.c
index d0182e2..900e120 100644
--- a/providers/postgres/gda-postgres-recordset.c
+++ b/providers/postgres/gda-postgres-recordset.c
@@ -311,7 +311,7 @@ finish_prep_stmt_init (PostgresConnectionData *cdata, GdaPostgresPStmt *ps, PGre
 			column = GDA_COLUMN (list->data);
 			postgres_type = PQftype (pg_res, i);
 			gtype = _GDA_PSTMT (ps)->types [i];
-			if (gtype == 0) {
+			if (gtype == GDA_TYPE_NULL) {
 				gtype = _gda_postgres_type_oid_to_gda (cdata->cnc, cdata->reuseable, postgres_type);
 				_GDA_PSTMT (ps)->types [i] = gtype;
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]