[gnome-db] Patch to change string escaping so SQLite will work
- From: Phil Longstaff <plongstaff rogers com>
- To: gnome-db-list gnome org, GnuCash development list <gnucash-devel gnucash org>
- Subject: [gnome-db] Patch to change string escaping so SQLite will work
- Date: Mon, 25 Feb 2008 15:13:34 -0500
I've attached a patch to change the default string escape for a
single-quote char from backslash single-quote (\') to single-quote
single-quote ('') so that SQLite will accept it. A better solution in
the long run is the modify the SQLite provider to use prepared statements.
The patch affects file libgda/gda-util.c.
Phil
--- gda-util.c.orig 2008-02-25 14:09:21.000000000 -0500
+++ gda-util.c 2008-02-25 14:35:03.000000000 -0500
@@ -85,7 +85,7 @@
* @string: string to escape
*
* Escapes @string to make it understandable by a DBMS. The escape method is very common and replaces any
- * occurence of "'" with "\'" and "\" with "\\".
+ * occurence of "'" with "''" and "\" with "\\"
*/
gchar *
gda_default_escape_string (const gchar *string)
@@ -111,7 +111,12 @@
ret = g_new0 (gchar, size);
retptr = ret;
while (*ptr) {
- if ((*ptr == '\'') || (*ptr == '\\')) {
+ if (*ptr == '\'') {
+ *retptr = '\'';
+ *(retptr+1) = *ptr;
+ retptr += 2;
+ }
+ else if (*ptr == '\\') {
*retptr = '\\';
*(retptr+1) = *ptr;
retptr += 2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]