Re: [gnome-db] Patch: gda-postgres update_row.



It would be usefull to either get the quote characters by querying the providers or wrap a column name with quotes for building complex queries.
eg.
char *quoted_identifier = gda_quote_identifier("mycol"); // returns 'mycol' etc.

I guess a bug report is probably the best place for this.. - BTW did anyone want to feed back on these

http://bugzilla.gnome.org/show_bug.cgi?id=160845 (mysql timestamp fix)
http://bugzilla.gnome.org/show_bug.cgi?id=160846 (expose escape string / delete escape stuff..)
http://bugzilla.gnome.org/show_bug.cgi?id=161068 (gda_version() addition)

I could try and throw a patch together for comment if no-one has any other better ideas.

Regards
Alan


Bas Driessen wrote:

Hello,

Attached a patch for the "update row" method for the Postgres provider. I made the following 3 changes:

-1 Place double quote (") around the field names in the SET part of the query. This allows for reserved names like "desc" to be used as fields names.

-2 Removed a call to function "gda_data_model_hash_update_row". This function does not exist, but even if it existed, a call to this function is not required. Within the function gda_postgres_recordset_update_row, the fields (or I have to call it data_model_columns now) are updated already and since those are pointers to the fields in the datamodel, there is no need to update a row in the datamodel with itself.

-3 Emit the correct 'updated' and 'changed' signals.

Please let me know any issues/concerns with this code or if OK when committed. The patch file is a diff against the latest cvs tree that includes Vivien's overhaul of DataModel from yesterday.

Thanks,
Bas,

------------------------------------------------------------------------

--- ChangeLog.orig	2005-01-11 10:49:34.873652188 +1000
+++ ChangeLog	2005-01-11 11:16:22.178133184 +1000
@@ -1,3 +1,11 @@
+2005-01-11  Bas Driessen <bas driessen xobas com>
+
+	* providers/postgres/gda-postgres-recordset.c
+	(gda_postgres_recordset_update_row):
+	use " for field names in 'SET' part of query.
+	remove unnecessary call to non-existent function gda_data_model_hash_update_row.
+	emit appropriate 'updated' and 'changed' signals.
+
2005-01-09  Vivien Malerba <malerba gnome-db org>
	* libgda/: Implemented GdaDataModel as an interface, and added a GdaDataModelBase class to serve
	  as a base class in relpacement of the previous GdaDataModel
--- providers/postgres/gda-postgres-recordset.c.orig	2005-01-11 10:51:29.059105686 +1000
+++ providers/postgres/gda-postgres-recordset.c	2005-01-11 11:10:24.605068574 +1000
@@ -386,7 +386,7 @@
		/* non-unique column: update it */
		else {
			/* fills the 'set' part of the update command */
- tmp = g_strdup_printf ("%s = '%s', ", + tmp = g_strdup_printf ("\"%s\" = '%s', ", column_name,
					       newval);
			query_set = g_strconcat (query_set, tmp, NULL);
@@ -439,8 +439,9 @@
	g_free (query_set);
	g_free (query_where);

-	if (status == TRUE)
-		status = GDA_DATA_MODEL_BASE_CLASS (parent_class)->update_row (model, row);
+	/* emit update signals */
+	gda_data_model_row_updated (GDA_DATA_MODEL (model), gda_row_get_number ((GdaRow *) row));
+	gda_data_model_changed (GDA_DATA_MODEL (model));

	return status;
}
------------------------------------------------------------------------

_______________________________________________
gnome-db-list mailing list
gnome-db-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-db-list




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