[libgda] Virtual connections: yet again improved column names of virtual tables
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Virtual connections: yet again improved column names of virtual tables
- Date: Sun, 3 Jun 2012 16:03:49 +0000 (UTC)
commit ba099ca65011166f969f957954af8595881b7178
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Jun 3 18:01:40 2012 +0200
Virtual connections: yet again improved column names of virtual tables
libgda/sqlite/virtual/gda-vprovider-data-model.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index a20f072..edff86f 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -585,8 +585,28 @@ virtualCreate (sqlite3 *db, void *pAux, int argc, const char *const *argv, sqlit
name = gda_column_get_name (column);
if (!name || !(*name))
newcolname = g_strdup_printf ("_%d", i + 1);
- else
+ else {
+ GString *string;
+ gchar *ptr;
+ string = g_string_new ("");
newcolname = gda_sql_identifier_quote (name, GDA_CONNECTION (cnc), NULL, FALSE, FALSE);
+ for (ptr = newcolname; *ptr; ptr++) {
+ if ((*ptr == '_') ||
+ ((*ptr >= 'a') && (*ptr <= 'z')) ||
+ ((*ptr >= 'A') && (*ptr <= 'Z')))
+ g_string_append_c (string, *ptr);
+ else if ((*ptr >= '0') && (*ptr <= '9')) {
+ if (ptr == name)
+ g_string_append_c (string, '_');
+ else
+ g_string_append_c (string, *ptr);
+ }
+ else
+ g_string_append_c (string, '_');
+ }
+ g_free (newcolname);
+ newcolname = g_string_free (string, FALSE);
+ }
tmp = g_ascii_strdown (newcolname, -1);
if (g_hash_table_lookup (hash, tmp)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]