[libgda/LIBGDA_4.0] GdaDataSelect corrections
- From: Vivien Malerba <vivien src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.0] GdaDataSelect corrections
- Date: Fri, 9 Oct 2009 19:31:04 +0000 (UTC)
commit 3de2260a8e756ac4097319a4c0dc954a0cf14521
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 | 30 ++++++++++++++----------------
libgda/gda-util.c | 24 ++++++++++++++++--------
3 files changed, 32 insertions(+), 26 deletions(-)
---
diff --git a/doc/C/store-meta-type.xml b/doc/C/store-meta-type.xml
index 9b66272..c79e99f 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 2b0aaf4..3792974 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -1268,27 +1268,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;
}
@@ -2876,10 +2875,9 @@ gda_data_select_append_values (GdaDataModel *model, const GList *values, GError
g_free (sql);
#endif
- if (! imodel->priv->modif_internals->one_row_select_stmt) {
- imodel->priv->modif_internals->one_row_select_stmt = compute_single_select_stmt (imodel, error);
- if (!imodel->priv->modif_internals->one_row_select_stmt)
- return -1;
+ 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);
}
GdaSet *last_insert;
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index eabae01..1bc2414 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -1004,9 +1004,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) {
@@ -1016,14 +1018,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);
@@ -1096,10 +1103,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]