[libgda] Make GdaBrowser's data manager perspective handle composed table names
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Make GdaBrowser's data manager perspective handle composed table names
- Date: Mon, 12 Jul 2010 20:21:00 +0000 (UTC)
commit 58247b1f465a277465bbb606cdcd6eb6b9e8ed6d
Author: Vivien Malerba <malerba gnome-db org>
Date: Mon Jul 12 19:29:12 2010 +0200
Make GdaBrowser's data manager perspective handle composed table names
tools/browser/data-manager/data-source.c | 25 +++++++++++++++++++++----
1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/tools/browser/data-manager/data-source.c b/tools/browser/data-manager/data-source.c
index e9b823f..6211af0 100644
--- a/tools/browser/data-manager/data-source.c
+++ b/tools/browser/data-manager/data-source.c
@@ -340,7 +340,9 @@ get_meta_table (DataSource *source, const gchar *table_name, GError **error)
{
GdaMetaStruct *mstruct;
GdaMetaDbObject *dbo;
- GValue *vname;
+ GValue *vname[3] = {NULL, NULL, NULL};
+ gchar **split;
+ gint len;
mstruct = browser_connection_get_meta_struct (source->priv->bcnc);
if (! mstruct) {
@@ -349,9 +351,24 @@ get_meta_table (DataSource *source, const gchar *table_name, GError **error)
return NULL;
}
- g_value_set_string ((vname = gda_value_new (G_TYPE_STRING)), table_name);
- dbo = gda_meta_struct_get_db_object (mstruct, NULL, NULL, vname);
- gda_value_free (vname);
+ split = gda_sql_identifier_split (table_name);
+ if (! split) {
+ g_set_error (error, 0, 0,
+ _("Malformed table name \"%s\""), table_name);
+ return NULL;
+ }
+ len = g_strv_length (split);
+ g_value_set_string ((vname[2] = gda_value_new (G_TYPE_STRING)), split[len - 1]);
+ if (len > 1)
+ g_value_set_string ((vname[1] = gda_value_new (G_TYPE_STRING)), split[len -2]);
+ if (len > 2)
+ g_value_set_string ((vname[0] = gda_value_new (G_TYPE_STRING)), split[len - 3]);
+
+ dbo = gda_meta_struct_get_db_object (mstruct, vname[0], vname[1], vname[2]);
+ if (vname[0]) gda_value_free (vname[0]);
+ if (vname[1]) gda_value_free (vname[1]);
+ if (vname[2]) gda_value_free (vname[2]);
+
if (! dbo) {
g_set_error (error, 0, 0,
_("Could not find the \"%s\" table"), table_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]