Re: [gnome-db] libgda escape_value() and schema retreival



Rodrigo- , thanks for looking at it/ addressing it.

Murray Cumming wrote:

This seems to add a function like this:

gboolean
gda_connection_escape_string (GdaConnection *cnc,
			      gchar *from,
			      const gchar *to,
			      unsigned long length)

So,

1. Why do we need to provide the length of the "from" string? Surely, all
strings in libgda are null-terminated?
Sorry dont know libgda that well to comment..

2. It seems to convert from "to" to "from". Isn't that a bit backwards?
Actually, it was a pretty straight copy from the original mysql_/pgsql_ functions that did the same thing. - the only justification for keeping that standard was probably that anyone who's familar with the API's would pick up libgda a minute bit faster..

3. Is this just for creating SQL-representations of text values? Surely
it's more useful to have a funciton to create a SQL representation of a
GValue, whatever type that GValue has.
I agree, That would be better, In reality though, it's only strings AFAIK that need escaping, and may be locale specific on the database (eg. BIG5 in a mysql db, has to watch out what it quotes..) so if it was implemented as a Gda_connection_value_to_Sql(Gda_connection, Gda_value,gchar) - only when the gda_value was a string, would the function be called.

4. Does this add the quotes, or do you need a big switch/case (switching
on the field type) block in the app for that?
actually, only a few types varchar/char/text need escaping (which are represented as a single type in gda? AFAIK), so it's not that huge a switch/case.

Regards
Alan


Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com




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