[libgda] GdaDataPivot: remove special characters from alias
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaDataPivot: remove special characters from alias
- Date: Wed, 28 Sep 2011 19:49:16 +0000 (UTC)
commit c97f9d210af5f9c6fa69344a032a8daec4f74a88
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Sep 28 21:49:07 2011 +0200
GdaDataPivot: remove special characters from alias
libgda/gda-data-pivot.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/libgda/gda-data-pivot.c b/libgda/gda-data-pivot.c
index 72ef680..e2f0902 100644
--- a/libgda/gda-data-pivot.c
+++ b/libgda/gda-data-pivot.c
@@ -1255,8 +1255,20 @@ parse_field_spec (GdaDataPivot *pivot, const gchar *field, const gchar *alias, G
parser = gda_connection_create_parser (pivot->priv->vcnc);
g_assert (parser);
- if (alias)
- sql = g_strdup_printf ("SELECT %s AS %s FROM " TABLE_NAME, field, alias);
+ if (alias && *alias) {
+ gchar *tmp, *ptr;
+ tmp = g_strdup (alias);
+ for (ptr = tmp; *ptr; ptr++) {
+ if (g_ascii_isdigit (*ptr)) {
+ if (ptr == tmp)
+ *ptr = '_';
+ }
+ else if (! g_ascii_isalpha (*ptr))
+ *ptr = '_';
+ }
+ sql = g_strdup_printf ("SELECT %s AS %s FROM " TABLE_NAME, field, tmp);
+ g_free (tmp);
+ }
else
sql = g_strdup_printf ("SELECT %s FROM " TABLE_NAME, field);
stmt = gda_sql_parser_parse_string (parser, sql, &remain, &lerror);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]