[libgda] GdaDataSelect corrections
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda] GdaDataSelect corrections
- Date: Fri, 9 Oct 2009 19:31:44 +0000 (UTC)
commit 8e938794423a785236cad2aa1e4de04878babf69
Author: Vivien Malerba <malerba gnome-db org>
Date: Fri Oct 9 20:57:26 2009 +0200
GdaDataSelect corrections
related to data models where the only problem
to be modifiable is that there is no primary key
defined in the table which is SELECTED, now it's
possible to insert data.
doc/C/store-meta-type.xml | 4 ++--
libgda/gda-data-select.c | 28 +++++++++++++---------------
libgda/gda-util.c | 24 ++++++++++++++++--------
3 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/doc/C/store-meta-type.xml b/doc/C/store-meta-type.xml
index c03a1d4..6c56ff1 100644
--- a/doc/C/store-meta-type.xml
+++ b/doc/C/store-meta-type.xml
@@ -95,7 +95,7 @@
<sect2 id="GdaConnectionMetaTypeGDA_CONNECTION_META_TABLES">
<title>GDA_CONNECTION_META_TABLES</title>
- <para>Lists the tables.
+ <para>Lists the tables which are "visible" without having to specify a schema name.
</para>
<para>Optional filter:
<itemizedlist>
@@ -126,7 +126,7 @@
<row>
<entry>2</entry>
<entry>G_TYPE_STRING</entry>
- <entry>Table's complete name (if the table is not in the default namespace)</entry>
+ <entry>Table's complete name (ie. schema name + table name)</entry>
</row>
<row>
<entry>3</entry>
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index f787de3..c839c9e 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -1222,27 +1222,26 @@ gda_data_select_compute_modification_statements (GdaDataSelect *model, GError **
&(modif_stmts[INS_QUERY]),
&(modif_stmts[UPD_QUERY]),
&(modif_stmts[DEL_QUERY]), error);
- if (retval) {
- for (mtype = FIRST_QUERY; mtype < NB_QUERIES; mtype++) {
+ for (mtype = FIRST_QUERY; mtype < NB_QUERIES; mtype++) {
#ifdef GDA_DEBUG_NO
+ if (modif_stmts[mtype]) {
gchar *sql;
sql = gda_statement_to_sql (modif_stmts[mtype], NULL, NULL);
g_print ("type %d => %s\n", mtype, sql);
g_free (sql);
+ }
#endif
- if (modif_stmts[mtype] &&
- ! gda_data_select_set_modification_statement (model, modif_stmts[mtype], error)) {
- retval = FALSE;
- break;
- }
+ if (modif_stmts[mtype] &&
+ ! gda_data_select_set_modification_statement (model, modif_stmts[mtype], error)) {
+ retval = FALSE;
}
}
- if (!retval) {
- for (mtype = FIRST_QUERY; mtype < NB_QUERIES; mtype++) {
- if (modif_stmts[mtype])
- g_object_unref (modif_stmts[mtype]);
- }
+
+ for (mtype = FIRST_QUERY; mtype < NB_QUERIES; mtype++) {
+ if (modif_stmts[mtype])
+ g_object_unref (modif_stmts[mtype]);
}
+
return retval;
}
@@ -2833,9 +2832,8 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
#endif
if (! imodel->priv->sh->modif_internals->one_row_select_stmt) {
- imodel->priv->sh->modif_internals->one_row_select_stmt = compute_single_select_stmt (imodel, error);
- if (!imodel->priv->sh->modif_internals->one_row_select_stmt)
- return -1;
+ imodel->priv->sh->modif_internals->one_row_select_stmt =
+ compute_single_select_stmt (imodel, error);
}
GdaSet *last_insert;
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index effb9c6..0befd4e 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -1003,9 +1003,11 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
require_pk, error);
if (!ust->cond) {
retval = FALSE;
- goto cleanup;
+ *update_stmt = NULL;
+ update_stmt = NULL; /* don't try anymore to build UPDATE statement */
}
- GDA_SQL_ANY_PART (ust->cond)->parent = GDA_SQL_ANY_PART (ust);
+ else
+ GDA_SQL_ANY_PART (ust->cond)->parent = GDA_SQL_ANY_PART (ust);
}
if (delete_stmt) {
@@ -1015,14 +1017,19 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
dst->table = gda_sql_table_new (GDA_SQL_ANY_PART (dst));
dst->table->table_name = g_strdup (tmp);
- dst->cond = gda_compute_unique_table_row_condition_with_cnc (cnc, stsel,
+ if (update_stmt && ust->cond)
+ dst->cond = gda_sql_expr_copy (ust->cond);
+ else
+ dst->cond = gda_compute_unique_table_row_condition_with_cnc (cnc, stsel,
GDA_META_TABLE (target->validity_meta_object),
require_pk, error);
if (!dst->cond) {
retval = FALSE;
- goto cleanup;
+ *delete_stmt = NULL;
+ delete_stmt = NULL; /* don't try anymore to build DELETE statement */
}
- GDA_SQL_ANY_PART (dst->cond)->parent = GDA_SQL_ANY_PART (dst);
+ else
+ GDA_SQL_ANY_PART (dst->cond)->parent = GDA_SQL_ANY_PART (dst);
}
g_free (tmp);
@@ -1094,10 +1101,11 @@ gda_compute_dml_statements (GdaConnection *cnc, GdaStatement *select_stmt, gbool
g_set_error (error, GDA_SQL_ERROR, GDA_SQL_STRUCTURE_CONTENTS_ERROR,
"%s", _("Could not compute any field to insert into"));
retval = FALSE;
- goto cleanup;
}
- ist->values_list = g_slist_append (NULL, insert_values_list);
- ret_insert = g_object_new (GDA_TYPE_STATEMENT, "structure", sql_ist, NULL);
+ else {
+ ist->values_list = g_slist_append (NULL, insert_values_list);
+ ret_insert = g_object_new (GDA_TYPE_STATEMENT, "structure", sql_ist, NULL);
+ }
}
if (update_stmt)
ret_update = g_object_new (GDA_TYPE_STATEMENT, "structure", sql_ust, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]