[libgda] GdaBrowser: better handle compound statements
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaBrowser: better handle compound statements
- Date: Tue, 8 Nov 2011 22:30:11 +0000 (UTC)
commit ab402551805175bfd945e6e86dc15b99792b37ca
Author: Vivien Malerba <malerba gnome-db org>
Date: Tue Nov 8 23:29:55 2011 +0100
GdaBrowser: better handle compound statements
tools/browser/common/ui-formgrid.c | 92 ++++++++++++++++++++++--------------
1 files changed, 57 insertions(+), 35 deletions(-)
---
diff --git a/tools/browser/common/ui-formgrid.c b/tools/browser/common/ui-formgrid.c
index 9c929e2..27cb0ea 100644
--- a/tools/browser/common/ui-formgrid.c
+++ b/tools/browser/common/ui-formgrid.c
@@ -900,6 +900,55 @@ ui_formgrid_new (GdaDataModel *model, gboolean scroll_form, GdauiDataProxyInfoFl
return (GtkWidget *) formgrid;
}
+static void
+handle_user_prefs_for_sql_statement (UiFormGrid *formgrid, BrowserConnection *bcnc,
+ GdaSqlStatement *sqlst)
+{
+ g_assert (sqlst);
+ if (sqlst->stmt_type == GDA_SQL_STATEMENT_COMPOUND) {
+ GdaSqlStatementCompound *comp;
+ GSList *list;
+ comp = (GdaSqlStatementCompound*) sqlst->contents;
+ for (list = comp->stmt_list; list; list = list->next)
+ handle_user_prefs_for_sql_statement (formgrid, bcnc,
+ (GdaSqlStatement *) list->data);
+ }
+ else {
+ GdaSet *set;
+ set = (GdaSet*) ui_formgrid_get_form_data_set (UI_FORMGRID (formgrid));
+
+ GdaSqlStatementSelect *sel;
+ GSList *list;
+ gint pos;
+ sel = (GdaSqlStatementSelect*) sqlst->contents;
+ for (pos = 0, list = sel->expr_list; list; pos ++, list = list->next) {
+ GdaSqlSelectField *field = (GdaSqlSelectField*) list->data;
+ if (! field->validity_meta_object ||
+ (field->validity_meta_object->obj_type != GDA_META_DB_TABLE) ||
+ !field->validity_meta_table_column)
+ continue;
+
+ gchar *plugin;
+ plugin = browser_connection_get_table_column_attribute (bcnc,
+ GDA_META_TABLE (field->validity_meta_object),
+ field->validity_meta_table_column,
+ BROWSER_CONNECTION_COLUMN_PLUGIN, NULL);
+ if (!plugin)
+ continue;
+
+ GdaHolder *holder;
+ holder = gda_set_get_nth_holder (set, pos);
+ if (holder) {
+ GValue *value;
+ value = gda_value_new_from_string (plugin, G_TYPE_STRING);
+ gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
+ gda_value_free (value);
+ }
+ g_free (plugin);
+ }
+ }
+}
+
/**
* ui_formgrid_handle_user_prefs
* @formgrid: a #UiFormGrid widget
@@ -929,43 +978,16 @@ ui_formgrid_handle_user_prefs (UiFormGrid *formgrid, BrowserConnection *bcnc, Gd
if (!sqlst)
return;
- if ((sqlst->stmt_type != GDA_SQL_STATEMENT_SELECT) ||
- !browser_connection_normalize_sql_statement (bcnc, sqlst, NULL))
- goto out;
-
- GdaSet *set;
- set = (GdaSet*) ui_formgrid_get_form_data_set (UI_FORMGRID (formgrid));
-
- GdaSqlStatementSelect *sel;
- GSList *list;
- gint pos;
- sel = (GdaSqlStatementSelect*) sqlst->contents;
- for (pos = 0, list = sel->expr_list; list; pos ++, list = list->next) {
- GdaSqlSelectField *field = (GdaSqlSelectField*) list->data;
- if (! field->validity_meta_object ||
- (field->validity_meta_object->obj_type != GDA_META_DB_TABLE) ||
- !field->validity_meta_table_column)
- continue;
-
- gchar *plugin;
- plugin = browser_connection_get_table_column_attribute (bcnc,
- GDA_META_TABLE (field->validity_meta_object),
- field->validity_meta_table_column,
- BROWSER_CONNECTION_COLUMN_PLUGIN, NULL);
- if (!plugin)
- continue;
-
- GdaHolder *holder;
- holder = gda_set_get_nth_holder (set, pos);
- if (holder) {
- GValue *value;
- value = gda_value_new_from_string (plugin, G_TYPE_STRING);
- gda_holder_set_attribute_static (holder, GDAUI_ATTRIBUTE_PLUGIN, value);
- gda_value_free (value);
- }
- g_free (plugin);
+ GError *lerror = NULL;
+ if (((sqlst->stmt_type != GDA_SQL_STATEMENT_SELECT) &&
+ (sqlst->stmt_type != GDA_SQL_STATEMENT_COMPOUND)) ||
+ !browser_connection_normalize_sql_statement (bcnc, sqlst, &lerror)) {
+ if (lerror)
+ g_print ("[%s]\n", lerror->message);
+ goto out;
}
+ handle_user_prefs_for_sql_statement (formgrid, bcnc, sqlst);
out:
gda_sql_statement_free (sqlst);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]