libgda r3204 - in trunk: . doc/C doc/C/tmpl libgda libgda-report/engine libgda/sql-parser libgda/sqlite libgda/sqlite/virtual providers/mdb providers/mysql providers/postgres tests/data-models tests/meta-store tests/parser tests/providers tests/value-holders tools
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgda r3204 - in trunk: . doc/C doc/C/tmpl libgda libgda-report/engine libgda/sql-parser libgda/sqlite libgda/sqlite/virtual providers/mdb providers/mysql providers/postgres tests/data-models tests/meta-store tests/parser tests/providers tests/value-holders tools
- Date: Tue, 9 Sep 2008 20:42:54 +0000 (UTC)
Author: vivien
Date: Tue Sep 9 20:42:53 2008
New Revision: 3204
URL: http://svn.gnome.org/viewvc/libgda?rev=3204&view=rev
Log:
2008-09-09 Vivien Malerba <malerba gnome-db org>
* libgda/sqlite/virtual/gda-virtual-connection.c:
* libgda/sqlite/gda-sqlite-recordset.c:
* libgda/gda-column.[ch]:
* libgda/gda-data-model.c:
* libgda/gda-data-model-import.c:
* libgda/gda-data-model-array.c: removed gda_column_[gs]et_table(), gda_column_[gs]et_caption(),
gda_column_[gs]et_scale(), gda_column_[gs]et_primary_key(), gda_column_[gs]et_unique_key(),
gda_column_[gs]et_references() and gda_column_[gs]et_defined_size() as they were useless
* libgda-report/engine/gda-report-engine.c: forgot to rename "spec-file" to "spec-filename"
property
* libgda/gda-data-select.c: added a "select-stmt" property to retreive (if available), the
GdaStatement object which was executed in order to created the GdaDataSelect data model.
* libgda/gda-data-model-iter.c: when the data model the iterator will be for is a GdaDataSelect,
then use the SELECT statement to set some holder's properties (such as NOT NULL and default value),
contributes to fixing bug #551058
* libgda/sqlite/gda-sqlite-recordset.c: don't set GdaColumn's properties as we can't determine them
correctly at this point, contributes to fixing bug #551058
* libgda/sqlite/virtual/gda-virtual-connection.c: added missing header file
* libgda/gda-data-select.c:
* libgda/gda-data-model-dsn-list.c: correctly implement the get_value_at() virtual method
* libgda/gda-util.c: bug fixed in gda_compute_unique_table_row_condition()
* tests/: tests update
* doc/C: doc. update
* libgda/gda-data-model.h:
* all GdaDataModel's implementations: added a new virtual method "i_iter_set_value" to
allow data modifications from a GdaDataModelIter
* libgda/gda-holder.[ch]:
* libgda/gda-set.[ch]: added GdaHoler "before-change" and GdaSet "before-holder-change" signals
to enable control over the values a GdaHolder can have
* libgda/gda-data-model-iter.c: use the new GdaDataModel's "i_iter_set_value" virtual method and
GdaSet's new signal
* Altered all the signal's names to use the '-' instead of '_'
* tools/gda-list-server-op.c: compilation warnings fixes
Modified:
trunk/ChangeLog
trunk/doc/C/libgda-4.0-sections.txt
trunk/doc/C/tmpl/gda-column.sgml
trunk/doc/C/tmpl/gda-data-select.sgml
trunk/doc/C/tmpl/gda-holder.sgml
trunk/doc/C/tmpl/gda-report-engine.sgml
trunk/doc/C/tmpl/gda-set.sgml
trunk/libgda-report/engine/gda-report-engine.c
trunk/libgda/gda-column.c
trunk/libgda/gda-column.h
trunk/libgda/gda-config.c
trunk/libgda/gda-connection.c
trunk/libgda/gda-data-access-wrapper.c
trunk/libgda/gda-data-comparator.c
trunk/libgda/gda-data-model-array.c
trunk/libgda/gda-data-model-bdb.c
trunk/libgda/gda-data-model-dir.c
trunk/libgda/gda-data-model-dsn-list.c
trunk/libgda/gda-data-model-import.c
trunk/libgda/gda-data-model-iter.c
trunk/libgda/gda-data-model-query.c
trunk/libgda/gda-data-model.c
trunk/libgda/gda-data-model.h
trunk/libgda/gda-data-proxy.c
trunk/libgda/gda-data-select.c
trunk/libgda/gda-holder.c
trunk/libgda/gda-holder.h
trunk/libgda/gda-marshal.list
trunk/libgda/gda-meta-store.c
trunk/libgda/gda-meta-struct-io.c
trunk/libgda/gda-meta-struct.c
trunk/libgda/gda-server-operation.c
trunk/libgda/gda-set.c
trunk/libgda/gda-set.h
trunk/libgda/gda-util.c
trunk/libgda/gda-xa-transaction.c
trunk/libgda/sql-parser/gda-statement-struct.c
trunk/libgda/sqlite/gda-sqlite-provider.c
trunk/libgda/sqlite/gda-sqlite-recordset.c
trunk/libgda/sqlite/virtual/gda-vconnection-hub.c
trunk/libgda/sqlite/virtual/gda-virtual-connection.c
trunk/providers/mdb/gda-mdb-provider.c
trunk/providers/mysql/gda-mysql-recordset.c
trunk/providers/postgres/gda-postgres-recordset.c
trunk/tests/data-models/check_data_proxy.c
trunk/tests/data-models/check_pmodel.c
trunk/tests/data-models/pmodel_data_customers.xml
trunk/tests/data-models/pmodel_data_locations.xml
trunk/tests/meta-store/common.c
trunk/tests/parser/testvalid.xml
trunk/tests/providers/DATA_actor.xml
trunk/tests/providers/DATA_film.xml
trunk/tests/providers/DATA_film_actor.xml
trunk/tests/providers/DATA_language.xml
trunk/tests/providers/TYPES_SCHEMA_PostgreSQL.xml
trunk/tests/providers/TYPES_SCHEMA_SQLite.xml
trunk/tests/value-holders/check_holder.c
trunk/tests/value-holders/check_set.c
trunk/tools/gda-list-server-op.c
Modified: trunk/doc/C/libgda-4.0-sections.txt
==============================================================================
--- trunk/doc/C/libgda-4.0-sections.txt (original)
+++ trunk/doc/C/libgda-4.0-sections.txt Tue Sep 9 20:42:53 2008
@@ -4,30 +4,16 @@
GdaColumn
gda_column_new
gda_column_copy
-gda_column_get_defined_size
-gda_column_set_defined_size
gda_column_get_name
gda_column_set_name
gda_column_get_title
gda_column_set_title
-gda_column_get_table
-gda_column_set_table
-gda_column_get_caption
-gda_column_set_caption
-gda_column_get_scale
-gda_column_set_scale
gda_column_get_dbms_type
gda_column_set_dbms_type
gda_column_get_g_type
gda_column_set_g_type
gda_column_get_allow_null
gda_column_set_allow_null
-gda_column_get_primary_key
-gda_column_set_primary_key
-gda_column_get_unique_key
-gda_column_set_unique_key
-gda_column_get_references
-gda_column_set_references
gda_column_get_auto_increment
gda_column_set_auto_increment
gda_column_get_position
@@ -1067,26 +1053,28 @@
<FILE>gda-set</FILE>
<TITLE>GdaSet</TITLE>
GdaSet
-GdaSetHint
-GdaSetNode
-GdaSetGroup
-GdaSetSource
gda_set_new
gda_set_copy
gda_set_new_inline
gda_set_new_from_spec_string
gda_set_new_from_spec_node
-gda_set_get_spec
+gda_set_is_valid
gda_set_get_holder_value
gda_set_set_holder_value
+<SUBSECTION>
gda_set_get_holder
gda_set_add_holder
gda_set_remove_holder
gda_set_merge_with_set
-gda_set_is_valid
+gda_set_get_spec
+<SUBSECTION>
+GdaSetNode
+GdaSetHint
gda_set_get_node
+GdaSetSource
gda_set_get_source_for_model
gda_set_get_source
+GdaSetGroup
gda_set_get_group
<SUBSECTION Standard>
GDA_IS_SET
Modified: trunk/doc/C/tmpl/gda-column.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-column.sgml (original)
+++ trunk/doc/C/tmpl/gda-column.sgml Tue Sep 9 20:42:53 2008
@@ -62,24 +62,6 @@
@Returns:
-<!-- ##### FUNCTION gda_column_get_defined_size ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_defined_size ##### -->
-<para>
-
-</para>
-
- column:
- size:
-
-
<!-- ##### FUNCTION gda_column_get_name ##### -->
<para>
@@ -116,60 +98,6 @@
@title:
-<!-- ##### FUNCTION gda_column_get_table ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_table ##### -->
-<para>
-
-</para>
-
- column:
- table:
-
-
-<!-- ##### FUNCTION gda_column_get_caption ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_caption ##### -->
-<para>
-
-</para>
-
- column:
- caption:
-
-
-<!-- ##### FUNCTION gda_column_get_scale ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_scale ##### -->
-<para>
-
-</para>
-
- column:
- scale:
-
-
<!-- ##### FUNCTION gda_column_get_dbms_type ##### -->
<para>
@@ -224,60 +152,6 @@
@allow:
-<!-- ##### FUNCTION gda_column_get_primary_key ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_primary_key ##### -->
-<para>
-
-</para>
-
- column:
- pk:
-
-
-<!-- ##### FUNCTION gda_column_get_unique_key ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_unique_key ##### -->
-<para>
-
-</para>
-
- column:
- uk:
-
-
-<!-- ##### FUNCTION gda_column_get_references ##### -->
-<para>
-
-</para>
-
- column:
- Returns:
-
-
-<!-- ##### FUNCTION gda_column_set_references ##### -->
-<para>
-
-</para>
-
- column:
- ref:
-
-
<!-- ##### FUNCTION gda_column_get_auto_increment ##### -->
<para>
Modified: trunk/doc/C/tmpl/gda-data-select.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-data-select.sgml (original)
+++ trunk/doc/C/tmpl/gda-data-select.sgml Tue Sep 9 20:42:53 2008
@@ -78,6 +78,11 @@
</para>
+<!-- ##### ARG GdaDataSelect:select-stmt ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG GdaDataSelect:store-all-rows ##### -->
<para>
Modified: trunk/doc/C/tmpl/gda-holder.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-holder.sgml (original)
+++ trunk/doc/C/tmpl/gda-holder.sgml Tue Sep 9 20:42:53 2008
@@ -24,6 +24,15 @@
</para>
+<!-- ##### SIGNAL GdaHolder::before-change ##### -->
+<para>
+
+</para>
+
+ gdaholder: the object which received the signal.
+ arg1:
+ Returns:
+
<!-- ##### SIGNAL GdaHolder::changed ##### -->
<para>
Modified: trunk/doc/C/tmpl/gda-report-engine.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-report-engine.sgml (original)
+++ trunk/doc/C/tmpl/gda-report-engine.sgml Tue Sep 9 20:42:53 2008
@@ -151,7 +151,7 @@
</para>
-<!-- ##### ARG GdaReportEngine:spec-file ##### -->
+<!-- ##### ARG GdaReportEngine:spec-filename ##### -->
<para>
</para>
Modified: trunk/doc/C/tmpl/gda-set.sgml
==============================================================================
--- trunk/doc/C/tmpl/gda-set.sgml (original)
+++ trunk/doc/C/tmpl/gda-set.sgml Tue Sep 9 20:42:53 2008
@@ -6,8 +6,13 @@
<!-- ##### SECTION Long_Description ##### -->
<para>
-The #GdaSet object is a container for several values (as #GdaHolder objects), which also offers
-different classifications of the group of #GdaHolder values.
+ The #GdaSet object is a container for several values (as #GdaHolder objects), which also offers
+ different classifications of the group of #GdaHolder values (see gda_set_get_node(), gda_set_get_source() or
+ gda_set_get_group()).
+</para>
+<para>
+ It is possible to control the values a #GdaHolder can have in the #GdaSet by connecting to the
+ <link linkend="GdaSet-before-holder-change">"before-holder-change"</link> signal.
</para>
<!-- ##### SECTION See_Also ##### -->
@@ -24,6 +29,16 @@
</para>
+<!-- ##### SIGNAL GdaSet::before-holder-change ##### -->
+<para>
+
+</para>
+
+ gdaset: the object which received the signal.
+ arg1:
+ arg2:
+ Returns:
+
<!-- ##### SIGNAL GdaSet::holder-attr-changed ##### -->
<para>
@@ -75,44 +90,6 @@
</para>
-<!-- ##### ENUM GdaSetHint ##### -->
-<para>
-
-</para>
-
- GDA_SET_HOLDER_READ_ONLY:
- GDA_SET_HOLDER_HIDE:
-
-<!-- ##### STRUCT GdaSetNode ##### -->
-<para>
-
-</para>
-
- holder:
- source_model:
- source_column:
- hint:
-
-<!-- ##### STRUCT GdaSetGroup ##### -->
-<para>
-
-</para>
-
- nodes:
- nodes_source:
-
-<!-- ##### STRUCT GdaSetSource ##### -->
-<para>
-
-</para>
-
- data_model:
- nodes:
- shown_n_cols:
- shown_cols_index:
- ref_n_cols:
- ref_cols_index:
-
<!-- ##### FUNCTION gda_set_new ##### -->
<para>
@@ -161,7 +138,7 @@
@Returns:
-<!-- ##### FUNCTION gda_set_get_spec ##### -->
+<!-- ##### FUNCTION gda_set_is_valid ##### -->
<para>
</para>
@@ -230,7 +207,7 @@
@set_to_merge:
-<!-- ##### FUNCTION gda_set_is_valid ##### -->
+<!-- ##### FUNCTION gda_set_get_spec ##### -->
<para>
</para>
@@ -239,6 +216,24 @@
@Returns:
+<!-- ##### STRUCT GdaSetNode ##### -->
+<para>
+
+</para>
+
+ holder:
+ source_model:
+ source_column:
+ hint:
+
+<!-- ##### ENUM GdaSetHint ##### -->
+<para>
+
+</para>
+
+ GDA_SET_HOLDER_READ_ONLY:
+ GDA_SET_HOLDER_HIDE:
+
<!-- ##### FUNCTION gda_set_get_node ##### -->
<para>
@@ -249,6 +244,18 @@
@Returns:
+<!-- ##### STRUCT GdaSetSource ##### -->
+<para>
+
+</para>
+
+ data_model:
+ nodes:
+ shown_n_cols:
+ shown_cols_index:
+ ref_n_cols:
+ ref_cols_index:
+
<!-- ##### FUNCTION gda_set_get_source_for_model ##### -->
<para>
@@ -269,6 +276,14 @@
@Returns:
+<!-- ##### STRUCT GdaSetGroup ##### -->
+<para>
+
+</para>
+
+ nodes:
+ nodes_source:
+
<!-- ##### FUNCTION gda_set_get_group ##### -->
<para>
Modified: trunk/libgda-report/engine/gda-report-engine.c
==============================================================================
--- trunk/libgda-report/engine/gda-report-engine.c (original)
+++ trunk/libgda-report/engine/gda-report-engine.c Tue Sep 9 20:42:53 2008
@@ -90,7 +90,7 @@
g_object_class_install_property (object_class, PROP_SPEC_STRING,
g_param_spec_string ("spec-string", NULL, NULL, NULL, G_PARAM_WRITABLE));
g_object_class_install_property (object_class, PROP_SPEC_FILE,
- g_param_spec_string ("spec-file", NULL, NULL, NULL, G_PARAM_WRITABLE));
+ g_param_spec_string ("spec-filename", NULL, NULL, NULL, G_PARAM_WRITABLE));
}
static void
Modified: trunk/libgda/gda-column.c
==============================================================================
--- trunk/libgda/gda-column.c (original)
+++ trunk/libgda/gda-column.c Tue Sep 9 20:42:53 2008
@@ -37,17 +37,10 @@
gchar *name;
gchar *title;
- gchar *table;
- gchar *caption;
- gint scale;
-
gchar *dbms_type;
GType g_type;
gboolean allow_null;
- gboolean primary_key;
- gboolean unique_key;
- gchar *references;
gboolean auto_increment;
glong auto_increment_start;
@@ -96,7 +89,7 @@
/* signals */
gda_column_signals[NAME_CHANGED] =
- g_signal_new ("name_changed",
+ g_signal_new ("name-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaColumnClass, name_changed),
@@ -105,7 +98,7 @@
G_TYPE_NONE,
1, G_TYPE_STRING);
gda_column_signals[GDA_TYPE_CHANGED] =
- g_signal_new ("g_type_changed",
+ g_signal_new ("g-type-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaColumnClass, g_type_changed),
@@ -134,15 +127,9 @@
column->priv->defined_size = 0;
column->priv->id = NULL;
column->priv->name = NULL;
- column->priv->table = NULL;
column->priv->title = NULL;
- column->priv->caption = NULL;
- column->priv->scale = 0;
column->priv->g_type = G_TYPE_INVALID;
column->priv->allow_null = TRUE;
- column->priv->primary_key = FALSE;
- column->priv->unique_key = FALSE;
- column->priv->references = NULL;
column->priv->auto_increment = FALSE;
column->priv->auto_increment_start = 0;
column->priv->auto_increment_step = 0;
@@ -161,12 +148,9 @@
if (column->priv->default_value)
gda_value_free (column->priv->default_value);
- g_free (column->priv->table);
g_free (column->priv->id);
g_free (column->priv->name);
g_free (column->priv->title);
- g_free (column->priv->caption);
- g_free (column->priv->references);
g_free (column->priv);
column->priv = NULL;
@@ -284,17 +268,8 @@
column_copy->priv->name = g_strdup (column->priv->name);
if (column->priv->title)
column_copy->priv->title = g_strdup (column->priv->title);
- if (column->priv->table)
- column_copy->priv->table = g_strdup (column->priv->table);
- if (column->priv->caption)
- column_copy->priv->caption = g_strdup (column->priv->caption);
- column_copy->priv->scale = column->priv->scale;
column_copy->priv->g_type = column->priv->g_type;
column_copy->priv->allow_null = column->priv->allow_null;
- column_copy->priv->primary_key = column->priv->primary_key;
- column_copy->priv->unique_key = column->priv->unique_key;
- if (column->priv->references)
- column_copy->priv->references = g_strdup (column->priv->references);
column_copy->priv->auto_increment = column->priv->auto_increment;
column_copy->priv->auto_increment_start = column->priv->auto_increment_start;
column_copy->priv->auto_increment_step = column->priv->auto_increment_step;
@@ -306,33 +281,6 @@
}
/**
- * gda_column_get_defined_size
- * @column: a @GdaColumn.
- *
- * Returns: the defined size of @column.
- */
-glong
-gda_column_get_defined_size (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), 0);
- return column->priv->defined_size;
-}
-
-/**
- * gda_column_set_defined_size
- * @column: a #GdaColumn.
- * @size: the defined size we want to set.
- *
- * Sets the defined size of a #GdaColumn.
- */
-void
-gda_column_set_defined_size (GdaColumn *column, glong size)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
- column->priv->defined_size = size;
-}
-
-/**
* gda_column_get_name
* @column: a #GdaColumn.
*
@@ -405,94 +353,6 @@
column->priv->title = g_strdup (title);
}
-
-/**
- * gda_column_get_table
- * @column: a #GdaColumn.
- *
- * Returns: the name of the table to which this column belongs.
- */
-const gchar *
-gda_column_get_table (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), NULL);
- return column->priv->table;;
-}
-
-/**
- * gda_column_set_table
- * @column: a #GdaColumn.
- * @table: table name.
- *
- * Sets the name of the table to which the given column belongs.
- */
-void
-gda_column_set_table (GdaColumn *column, const gchar *table)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
-
- if (column->priv->table != NULL)
- g_free (column->priv->table);
- column->priv->table = g_strdup (table);
-}
-
-/**
- * gda_column_get_caption
- * @column: a #GdaColumn.
- *
- * Returns: @column's caption.
- */
-const gchar *
-gda_column_get_caption (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), NULL);
- return (const gchar *) column->priv->caption;
-}
-
-/**
- * gda_column_set_caption
- * @column: a #GdaColumn.
- * @caption: caption.
- *
- * Sets @column's @caption.
- */
-void
-gda_column_set_caption (GdaColumn *column, const gchar *caption)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
-
- if (column->priv->caption)
- g_free (column->priv->caption);
- column->priv->caption = g_strdup (caption);
-}
-
-/**
- * gda_column_get_scale
- * @column: a #GdaColumn.
- *
- * Returns: the number of decimals of @column.
- */
-glong
-gda_column_get_scale (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), 0);
- return column->priv->scale;
-}
-
-/**
- * gda_column_set_scale
- * @column: a #GdaColumn.
- * @scale: number of decimals.
- *
- * Sets the scale of @column to @scale.
- */
-void
-gda_column_set_scale (GdaColumn *column, glong scale)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
- column->priv->scale = scale;
-}
-
/**
* gda_column_get_dbms_type
* @column: a #GdaColumn.
@@ -585,97 +445,6 @@
}
/**
- * gda_column_get_primary_key
- * @column: a #GdaColumn.
- *
- * Returns: whether if the given column is a primary key (%TRUE or %FALSE).
- */
-gboolean
-gda_column_get_primary_key (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), FALSE);
- return column->priv->primary_key;
-}
-
-/**
- * gda_column_set_primary_key
- * @column: a #GdaColumn.
- * @pk: whether if the given column should be a primary key.
- *
- * Sets the 'primary key' flag of the given column.
- */
-void
-gda_column_set_primary_key (GdaColumn *column, gboolean pk)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
- column->priv->primary_key = pk;
-}
-
-/**
- * gda_column_get_unique_key
- * @column: a #GdaColumn.
- *
- * Returns: whether if the given column is an unique key (%TRUE or %FALSE).
- */
-gboolean
-gda_column_get_unique_key (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), FALSE);
- return column->priv->unique_key;
-}
-
-/**
- * gda_column_set_unique_key
- * @column: a #GdaColumn.
- * @uk: whether if the given column should be an unique key.
- *
- * Sets the 'unique key' flag of the given column.
- */
-void
-gda_column_set_unique_key (GdaColumn *column, gboolean uk)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
- column->priv->unique_key = uk;
-}
-
-/**
- * gda_column_get_references
- * @column: a #GdaColumn.
- *
- * Reference is returned in tablename.fieldname format. Do not free
- * this variable, it is used internally within GdaColumn.
- *
- * Returns: @column's references.
- */
-const gchar *
-gda_column_get_references (GdaColumn *column)
-{
- g_return_val_if_fail (GDA_IS_COLUMN (column), NULL);
- return (const gchar *) column->priv->references;
-}
-
-/**
- * gda_column_set_references
- * @column: a #GdaColumn.
- * @ref: references.
- *
- * Sets @column's @references.
- */
-void
-gda_column_set_references (GdaColumn *column, const gchar *ref)
-{
- g_return_if_fail (GDA_IS_COLUMN (column));
-
- if (column->priv->references != NULL) {
- g_free (column->priv->references);
- column->priv->references = NULL;
- }
-
- if (ref)
- column->priv->references = g_strdup (ref);
-}
-
-/**
* gda_column_get_auto_increment
* @column: a #GdaColumn.
*
Modified: trunk/libgda/gda-column.h
==============================================================================
--- trunk/libgda/gda-column.h (original)
+++ trunk/libgda/gda-column.h Tue Sep 9 20:42:53 2008
@@ -59,21 +59,9 @@
const gchar *gda_column_get_title (GdaColumn *column);
void gda_column_set_title (GdaColumn *column, const gchar *title);
-glong gda_column_get_defined_size (GdaColumn *column);
-void gda_column_set_defined_size (GdaColumn *column, glong size);
-
const gchar *gda_column_get_name (GdaColumn *column);
void gda_column_set_name (GdaColumn *column, const gchar *name);
-const gchar *gda_column_get_table (GdaColumn *column);
-void gda_column_set_table (GdaColumn *column, const gchar *table);
-
-const gchar *gda_column_get_caption (GdaColumn *column);
-void gda_column_set_caption (GdaColumn *column, const gchar *caption);
-
-glong gda_column_get_scale (GdaColumn *column);
-void gda_column_set_scale (GdaColumn *column, glong scale);
-
const gchar* gda_column_get_dbms_type (GdaColumn *column);
void gda_column_set_dbms_type (GdaColumn *column, const gchar *dbms_type);
@@ -83,15 +71,6 @@
gboolean gda_column_get_allow_null (GdaColumn *column);
void gda_column_set_allow_null (GdaColumn *column, gboolean allow);
-gboolean gda_column_get_primary_key (GdaColumn *column);
-void gda_column_set_primary_key (GdaColumn *column, gboolean pk);
-
-gboolean gda_column_get_unique_key (GdaColumn *column);
-void gda_column_set_unique_key (GdaColumn *column, gboolean uk);
-
-const gchar *gda_column_get_references (GdaColumn *column);
-void gda_column_set_references (GdaColumn *column, const gchar *ref);
-
gboolean gda_column_get_auto_increment (GdaColumn *column);
void gda_column_set_auto_increment (GdaColumn *column, gboolean is_auto);
Modified: trunk/libgda/gda-config.c
==============================================================================
--- trunk/libgda/gda-config.c (original)
+++ trunk/libgda/gda-config.c Tue Sep 9 20:42:53 2008
@@ -135,7 +135,7 @@
parent_class = g_type_class_peek_parent (klass);
gda_config_signals[DSN_ADDED] =
- g_signal_new ("dsn_added",
+ g_signal_new ("dsn-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaConfigClass, dsn_added),
@@ -143,7 +143,7 @@
gda_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
gda_config_signals[DSN_TO_BE_REMOVED] =
- g_signal_new ("dsn_to_be_removed",
+ g_signal_new ("dsn-to-be-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaConfigClass, dsn_to_be_removed),
@@ -151,7 +151,7 @@
gda_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
gda_config_signals[DSN_REMOVED] =
- g_signal_new ("dsn_removed",
+ g_signal_new ("dsn-removed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaConfigClass, dsn_removed),
@@ -159,7 +159,7 @@
gda_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
gda_config_signals[DSN_CHANGED] =
- g_signal_new ("dsn_changed",
+ g_signal_new ("dsn-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaConfigClass, dsn_changed),
Modified: trunk/libgda/gda-connection.c
==============================================================================
--- trunk/libgda/gda-connection.c (original)
+++ trunk/libgda/gda-connection.c Tue Sep 9 20:42:53 2008
@@ -140,7 +140,7 @@
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1, GDA_TYPE_CONNECTION_EVENT);
gda_connection_signals[CONN_OPENED] =
- g_signal_new ("conn_opened",
+ g_signal_new ("conn-opened",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaConnectionClass, conn_opened),
@@ -148,7 +148,7 @@
gda_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gda_connection_signals[CONN_TO_CLOSE] =
- g_signal_new ("conn_to_close",
+ g_signal_new ("conn-to-close",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaConnectionClass, conn_to_close),
@@ -156,7 +156,7 @@
gda_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gda_connection_signals[CONN_CLOSED] = /* runs after user handlers */
- g_signal_new ("conn_closed",
+ g_signal_new ("conn-closed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaConnectionClass, conn_closed),
@@ -164,7 +164,7 @@
gda_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gda_connection_signals[DSN_CHANGED] =
- g_signal_new ("dsn_changed",
+ g_signal_new ("dsn-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaConnectionClass, dsn_changed),
@@ -172,7 +172,7 @@
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gda_connection_signals[TRANSACTION_STATUS_CHANGED] =
- g_signal_new ("transaction_status_changed",
+ g_signal_new ("transaction-status-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaConnectionClass, transaction_status_changed),
@@ -858,7 +858,7 @@
* @cnc: a #GdaConnection object.
*
* Closes the connection to the underlying data source, but first emits the
- * "conn_to_close" signal.
+ * "conn-to-close" signal.
*/
void
gda_connection_close (GdaConnection *cnc)
@@ -2934,7 +2934,7 @@
g_hash_table_insert (cbd.context_templates_hash, ((GdaMetaContext*)list->data)->table_name,
list->data);
- signal_id = g_signal_connect (store, "suggest_update",
+ signal_id = g_signal_connect (store, "suggest-update",
G_CALLBACK (suggest_update_cb_downstream), &cbd);
retval = local_meta_update (cnc->priv->provider_obj, cnc,
Modified: trunk/libgda/gda-data-access-wrapper.c
==============================================================================
--- trunk/libgda/gda-data-access-wrapper.c (original)
+++ trunk/libgda/gda-data-access-wrapper.c Tue Sep 9 20:42:53 2008
@@ -160,6 +160,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = NULL;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = NULL;
iface->i_append_values = NULL;
iface->i_append_row = NULL;
@@ -282,20 +283,20 @@
if (! (model->priv->model_access_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
model->priv->iter = gda_data_model_create_iter (mod);
g_return_if_fail (model->priv->iter);
- g_signal_connect (G_OBJECT (model->priv->iter), "row_changed",
+ g_signal_connect (G_OBJECT (model->priv->iter), "row-changed",
G_CALLBACK (iter_row_changed_cb), model);
- g_signal_connect (G_OBJECT (model->priv->iter), "end_of_data",
+ g_signal_connect (G_OBJECT (model->priv->iter), "end-of-data",
G_CALLBACK (iter_end_of_data_cb), model);
model->priv->iter_row = -1; /* because model->priv->iter is invalid */
model->priv->rows = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, (GDestroyNotify) g_object_unref);
}
else {
- g_signal_connect (G_OBJECT (mod), "row_inserted",
+ g_signal_connect (G_OBJECT (mod), "row-inserted",
G_CALLBACK (model_row_inserted_cb), model);
- g_signal_connect (G_OBJECT (mod), "row_updated",
+ g_signal_connect (G_OBJECT (mod), "row-updated",
G_CALLBACK (model_row_updated_cb), model);
- g_signal_connect (G_OBJECT (mod), "row_removed",
+ g_signal_connect (G_OBJECT (mod), "row-removed",
G_CALLBACK (model_row_removed_cb), model);
}
@@ -468,7 +469,7 @@
if (col >= imodel->priv->nb_cols) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_COLUMN_OUT_OF_RANGE_ERROR,
- _("Column %d out of range (0-%d)"), col, imodel->priv->nb_cols);
+ _("Column %d out of range (0-%d)"), col, imodel->priv->nb_cols - 1);
return NULL;
}
Modified: trunk/libgda/gda-data-comparator.c
==============================================================================
--- trunk/libgda/gda-data-comparator.c (original)
+++ trunk/libgda/gda-data-comparator.c Tue Sep 9 20:42:53 2008
@@ -139,7 +139,7 @@
/* signals */
gda_data_comparator_signals [DIFF_COMPUTED] =
- g_signal_new ("diff_computed",
+ g_signal_new ("diff-computed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaDataComparatorClass, diff_computed),
Modified: trunk/libgda/gda-data-model-array.c
==============================================================================
--- trunk/libgda/gda-data-model-array.c (original)
+++ trunk/libgda/gda-data-model-array.c Tue Sep 9 20:42:53 2008
@@ -97,6 +97,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = gda_data_model_array_set_value_at;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = gda_data_model_array_set_values;
iface->i_append_values = gda_data_model_array_append_values;
iface->i_append_row = gda_data_model_array_append_row;
@@ -349,10 +350,7 @@
g_object_set (G_OBJECT (copycol), "id", colid, NULL);
g_free (colid);
gda_column_set_title (copycol, gda_column_get_title (srccol));
- gda_column_set_defined_size (copycol, gda_column_get_defined_size (srccol));
gda_column_set_name (copycol, gda_column_get_name (srccol));
- gda_column_set_caption (copycol, gda_column_get_caption (srccol));
- gda_column_set_scale (copycol, gda_column_get_scale (srccol));
gda_column_set_dbms_type (copycol, gda_column_get_dbms_type (srccol));
gda_column_set_g_type (copycol, gda_column_get_g_type (srccol));
gda_column_set_position (copycol, gda_column_get_position (srccol));
@@ -385,7 +383,7 @@
g_return_val_if_fail (GDA_IS_DATA_MODEL_ARRAY (model), NULL);
if (row >= model->priv->rows->len) {
- g_set_error (error, GDA_DATA_MODEL_ERROR, 0,
+ g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ROW_OUT_OF_RANGE_ERROR,
_("Row %d out of range (0-%d)"), row,
model->priv->rows->len- 1);
return NULL;
@@ -462,7 +460,7 @@
GINT_TO_POINTER (col));
if (!column) {
column = gda_column_new ();
- g_signal_connect (G_OBJECT (column), "g_type_changed",
+ g_signal_connect (G_OBJECT (column), "g-type-changed",
G_CALLBACK (column_g_type_changed_cb), model);
gda_column_set_position (column, col);
g_hash_table_insert (((GdaDataModelArray*) model)->priv->column_spec,
Modified: trunk/libgda/gda-data-model-bdb.c
==============================================================================
--- trunk/libgda/gda-data-model-bdb.c (original)
+++ trunk/libgda/gda-data-model-bdb.c Tue Sep 9 20:42:53 2008
@@ -115,6 +115,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = gda_data_model_bdb_set_value_at;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = gda_data_model_bdb_set_values;
iface->i_append_values = gda_data_model_bdb_append_values;
iface->i_append_row = gda_data_model_bdb_append_row;
Modified: trunk/libgda/gda-data-model-dir.c
==============================================================================
--- trunk/libgda/gda-data-model-dir.c (original)
+++ trunk/libgda/gda-data-model-dir.c Tue Sep 9 20:42:53 2008
@@ -161,6 +161,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = gda_data_model_dir_set_value_at;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = gda_data_model_dir_set_values;
iface->i_append_values = gda_data_model_dir_append_values;
iface->i_append_row = NULL;
Modified: trunk/libgda/gda-data-model-dsn-list.c
==============================================================================
--- trunk/libgda/gda-data-model-dsn-list.c (original)
+++ trunk/libgda/gda-data-model-dsn-list.c Tue Sep 9 20:42:53 2008
@@ -47,7 +47,7 @@
static gint gda_data_model_dsn_list_get_n_columns (GdaDataModel *model);
static GdaColumn *gda_data_model_dsn_list_describe_column (GdaDataModel *model, gint col);
static GdaDataModelAccessFlags gda_data_model_dsn_list_get_access_flags(GdaDataModel *model);
-static const GValue *gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row);
+static const GValue *gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row, GError **error);
static GdaValueAttribute gda_data_model_dsn_list_get_attributes_at (GdaDataModel *model, gint col, gint row);
static GObjectClass *parent_class = NULL;
@@ -76,6 +76,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = NULL;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = NULL;
iface->i_append_values = NULL;
iface->i_append_row = NULL;
@@ -141,13 +142,13 @@
g_object_set_data (G_OBJECT (model), "name", _("List of defined data sources"));
config = gda_config_get ();
- g_signal_connect (G_OBJECT (config), "dsn_added",
+ g_signal_connect (G_OBJECT (config), "dsn-added",
G_CALLBACK (dsn_added_cb), model);
- g_signal_connect (G_OBJECT (config), "dsn_to_be_removed",
+ g_signal_connect (G_OBJECT (config), "dsn-to-be-removed",
G_CALLBACK (dsn_to_be_removed_cb), model);
- g_signal_connect (G_OBJECT (config), "dsn_removed",
+ g_signal_connect (G_OBJECT (config), "dsn-removed",
G_CALLBACK (dsn_removed_cb), model);
- g_signal_connect (G_OBJECT (config), "dsn_changed",
+ g_signal_connect (G_OBJECT (config), "dsn-changed",
G_CALLBACK (dsn_changed_cb), model);
model->priv->tmp_value = NULL;
@@ -295,7 +296,7 @@
}
static const GValue *
-gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row)
+gda_data_model_dsn_list_get_value_at (GdaDataModel *model, gint col, gint row, GError **error)
{
GdaDataModelDsnList *dmodel = GDA_DATA_MODEL_DSN_LIST (model);
@@ -304,44 +305,54 @@
dmodel->priv->tmp_value = NULL;
}
- if ((col < gda_data_model_dsn_list_get_n_columns (model)) &&
- (col >= 0) && (row >=0) && (row < gda_data_model_dsn_list_get_n_rows (model))) {
- GdaDataSourceInfo *info = gda_config_get_dsn_at_index (row);
- g_assert (info);
- if (col != 5)
- dmodel->priv->tmp_value = gda_value_new (G_TYPE_STRING);
- else
- dmodel->priv->tmp_value = gda_value_new (G_TYPE_BOOLEAN);
- switch (col) {
- case 0:
- g_value_set_string (dmodel->priv->tmp_value, info->name);
- break;
- case 1:
- g_value_set_string (dmodel->priv->tmp_value, info->provider);
- break;
- case 2:
- g_value_set_string (dmodel->priv->tmp_value, info->description);
- break;
- case 3:
- g_value_set_string (dmodel->priv->tmp_value, info->cnc_string);
- break;
- case 4:
- if (info->auth_string) {
- GdaQuarkList* ql;
- ql = gda_quark_list_new_from_string (info->auth_string);
-
- g_value_set_string (dmodel->priv->tmp_value, gda_quark_list_find (ql, "USERNAME"));
- gda_quark_list_free (ql);
- }
- else
- g_value_set_string (dmodel->priv->tmp_value, "");
- break;
- case 5:
- g_value_set_boolean (dmodel->priv->tmp_value, info->is_system);
- break;
- default:
- g_assert_not_reached ();
+ if ((col >= gda_data_model_dsn_list_get_n_columns (model)) ||
+ (col < 0)) {
+ g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_COLUMN_OUT_OF_RANGE_ERROR,
+ _("Column %d out of range (0-%d)"), col, gda_data_model_dsn_list_get_n_columns (model) - 1);
+ return NULL;
+ }
+ if ((row < 0) || (row >= gda_data_model_dsn_list_get_n_rows (model))) {
+ g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ROW_OUT_OF_RANGE_ERROR,
+ _("Row %d out of range (0-%d)"), row,
+ gda_data_model_dsn_list_get_n_rows (model) - 1);
+ return NULL;
+ }
+
+ GdaDataSourceInfo *info = gda_config_get_dsn_at_index (row);
+ g_assert (info);
+ if (col != 5)
+ dmodel->priv->tmp_value = gda_value_new (G_TYPE_STRING);
+ else
+ dmodel->priv->tmp_value = gda_value_new (G_TYPE_BOOLEAN);
+ switch (col) {
+ case 0:
+ g_value_set_string (dmodel->priv->tmp_value, info->name);
+ break;
+ case 1:
+ g_value_set_string (dmodel->priv->tmp_value, info->provider);
+ break;
+ case 2:
+ g_value_set_string (dmodel->priv->tmp_value, info->description);
+ break;
+ case 3:
+ g_value_set_string (dmodel->priv->tmp_value, info->cnc_string);
+ break;
+ case 4:
+ if (info->auth_string) {
+ GdaQuarkList* ql;
+ ql = gda_quark_list_new_from_string (info->auth_string);
+
+ g_value_set_string (dmodel->priv->tmp_value, gda_quark_list_find (ql, "USERNAME"));
+ gda_quark_list_free (ql);
}
+ else
+ g_value_set_string (dmodel->priv->tmp_value, "");
+ break;
+ case 5:
+ g_value_set_boolean (dmodel->priv->tmp_value, info->is_system);
+ break;
+ default:
+ g_assert_not_reached ();
}
return dmodel->priv->tmp_value;
Modified: trunk/libgda/gda-data-model-import.c
==============================================================================
--- trunk/libgda/gda-data-model-import.c (original)
+++ trunk/libgda/gda-data-model-import.c Tue Sep 9 20:42:53 2008
@@ -266,6 +266,7 @@
iface->i_iter_prev = gda_data_model_import_iter_prev;
iface->i_set_value_at = NULL;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = NULL;
iface->i_append_values = NULL;
iface->i_append_row = NULL;
@@ -819,7 +820,6 @@
str = g_strdup_printf ("column_%d", col);
gda_column_set_name (column, str);
gda_column_set_title (column, str);
- gda_column_set_caption (column, str);
g_free (str);
gda_column_set_g_type (column, G_TYPE_STRING);
@@ -1233,16 +1233,9 @@
g_object_set (G_OBJECT (column), "id", spec->id, NULL);
gda_column_set_title (column, (gchar*)spec->title);
gda_column_set_name (column, (gchar*)spec->name);
- gda_column_set_defined_size (column, spec->size);
- gda_column_set_caption (column, (gchar*)spec->caption);
gda_column_set_dbms_type (column, (gchar*)spec->dbms_type);
- gda_column_set_scale (column, spec->scale);
gda_column_set_g_type (column, spec->gdatype);
gda_column_set_allow_null (column, spec->nullok);
- gda_column_set_primary_key (column, spec->pkey);
- gda_column_set_unique_key (column, spec->unique);
- gda_column_set_table (column, (gchar*)spec->table);
- gda_column_set_references (column, (gchar*)spec->ref);
list = g_slist_next (list);
pos++;
@@ -1571,16 +1564,9 @@
g_object_set (G_OBJECT (column), "id", spec->id, NULL);
gda_column_set_title (column, (gchar*)spec->title);
gda_column_set_name (column, (gchar*)spec->name);
- gda_column_set_defined_size (column, spec->size);
- gda_column_set_caption (column, (gchar*)spec->caption);
gda_column_set_dbms_type (column, (gchar*)spec->dbms_type);
- gda_column_set_scale (column, spec->scale);
gda_column_set_g_type (column, spec->gdatype);
gda_column_set_allow_null (column, spec->nullok);
- gda_column_set_primary_key (column, spec->pkey);
- gda_column_set_unique_key (column, spec->unique);
- gda_column_set_table (column, (gchar*)spec->table);
- gda_column_set_references (column, (gchar*)spec->ref);
model->priv->columns = g_slist_prepend (model->priv->columns, gda_column_copy (column));
@@ -1901,7 +1887,7 @@
return allok;
}
else {
- g_signal_emit_by_name (iter, "end_of_data");
+ g_signal_emit_by_name (iter, "end-of-data");
g_object_set (G_OBJECT (iter), "current-row", -1, NULL);
return FALSE;
}
Modified: trunk/libgda/gda-data-model-iter.c
==============================================================================
--- trunk/libgda/gda-data-model-iter.c (original)
+++ trunk/libgda/gda-data-model-iter.c Tue Sep 9 20:42:53 2008
@@ -27,6 +27,7 @@
#include "gda-marshal.h"
#include "gda-data-proxy.h"
#include "gda-enums.h"
+#include "gda-data-select.h"
/*
* Main static functions
@@ -49,7 +50,7 @@
static void model_row_updated_cb (GdaDataModel *model, gint row, GdaDataModelIter *iter);
static void model_row_removed_cb (GdaDataModel *model, gint row, GdaDataModelIter *iter);
-static void holder_changed_cb (GdaSet *paramlist, GdaHolder *param);
+static GError *before_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *new_value);
static void holder_attr_changed_cb (GdaSet *paramlist, GdaHolder *param);
/* get a pointer to the parents to be able to cvalue their destructor */
@@ -152,21 +153,21 @@
parent_class = g_type_class_peek_parent (class);
gda_data_model_iter_signals [ROW_TO_CHANGE] =
- g_signal_new ("row_to_change",
+ g_signal_new ("row-to-change",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaDataModelIterClass, row_to_change),
row_to_change_accumulator, NULL,
gda_marshal_BOOLEAN__INT, G_TYPE_BOOLEAN, 1, G_TYPE_INT);
gda_data_model_iter_signals [ROW_CHANGED] =
- g_signal_new ("row_changed",
+ g_signal_new ("row-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaDataModelIterClass, row_changed),
NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gda_data_model_iter_signals [END_OF_DATA] =
- g_signal_new ("end_of_data",
+ g_signal_new ("end-of-data",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaDataModelIterClass, end_of_data),
@@ -179,7 +180,7 @@
object_class->dispose = gda_data_model_iter_dispose;
object_class->finalize = gda_data_model_iter_finalize;
- paramlist_class->holder_changed = holder_changed_cb;
+ paramlist_class->before_holder_change = before_holder_change_cb;
paramlist_class->holder_attr_changed = holder_attr_changed_cb;
/* Properties */
@@ -251,13 +252,14 @@
/*
* This function is called when a parameter in @paramlist is changed
* to make sure the change is propagated to the GdaDataModel
- * paramlist is an iter for
+ * paramlist is an iter for, return an error if the data model could not be modified
*/
-static void
-holder_changed_cb (GdaSet *paramlist, GdaHolder *param)
+static GError *
+before_holder_change_cb (GdaSet *paramlist, GdaHolder *param, const GValue *new_value)
{
GdaDataModelIter *iter;
gint col;
+ GError *error = NULL;
iter = (GdaDataModelIter *) paramlist;
if (!iter->priv->keep_param_changes && (iter->priv->row >= 0)) {
@@ -266,26 +268,33 @@
/* propagate the value update to the data model */
col = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (param), "model_col")) - 1;
- g_return_if_fail (col >= 0);
-
- if (! gda_data_model_set_value_at ((GdaDataModel *) iter->priv->data_model,
- col, iter->priv->row, gda_holder_get_value (param), NULL)) {
- /* writing to the model failed, revert back the change to parameter */
- const GValue *cvalue = gda_data_model_get_value_at (GDA_DATA_MODEL (iter->priv->data_model),
- col, iter->priv->row, NULL);
- iter->priv->keep_param_changes = TRUE;
- if (!cvalue || !gda_holder_set_value (param, cvalue, NULL))
- gda_holder_force_invalid (param);
- iter->priv->keep_param_changes = FALSE;
+ if (col < 0)
+ g_set_error (&error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_COLUMN_OUT_OF_RANGE_ERROR,
+ _("Column %d out of range (0-%d)"), col, g_slist_length (paramlist->holders) - 1);
+ else if (GDA_DATA_MODEL_GET_CLASS ((GdaDataModel *) iter->priv->data_model)->i_iter_set_value) {
+ if (! (GDA_DATA_MODEL_GET_CLASS ((GdaDataModel *) iter->priv->data_model)->i_iter_set_value)
+ ((GdaDataModel *) iter->priv->data_model, iter, col, new_value, &error)) {
+ if (!error)
+ g_set_error (&error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
+ _("GdaDataModel refused value change"));
+ }
+ }
+ else if (! gda_data_model_set_value_at ((GdaDataModel *) iter->priv->data_model,
+ col, iter->priv->row, gda_holder_get_value (param), &error)) {
+ if (!error)
+ g_set_error (&error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
+ _("GdaDataModel refused value change"));
}
g_signal_handler_unblock (iter->priv->data_model, iter->priv->model_changes_signals [0]);
g_signal_handler_unblock (iter->priv->data_model, iter->priv->model_changes_signals [1]);
}
- /* for the parent class */
- if (((GdaSetClass *) parent_class)->holder_changed)
- ((GdaSetClass *) parent_class)->holder_changed (paramlist, param);
+ if (!error && ((GdaSetClass *) parent_class)->before_holder_change)
+ /* for the parent class */
+ return ((GdaSetClass *) parent_class)->before_holder_change (paramlist, param, new_value);
+
+ return error;
}
/*
@@ -368,6 +377,79 @@
parent_class->finalize (object);
}
+static void
+set_holders_properties_from_select_stmt (GdaDataModelIter *iter, GdaConnection *cnc, GdaStatement *sel_stmt)
+{
+ GdaSqlStatement *sqlst = NULL;
+ GdaSqlStatementSelect *select;
+ GdaSqlSelectTarget *target;
+
+ g_object_get (G_OBJECT (sel_stmt), "structure", &sqlst, NULL);
+ g_assert (sqlst->stmt_type == GDA_SQL_STATEMENT_SELECT);
+ select = (GdaSqlStatementSelect*) sqlst->contents;
+
+ /* we only want a single target */
+ if (!select->from || !select->from->targets || select->from->targets->next)
+ goto out;
+
+ target = (GdaSqlSelectTarget *) select->from->targets->data;
+ if (!target || !target->table_name)
+ goto out;
+
+ if (! gda_sql_statement_check_validity (sqlst, cnc, NULL))
+ goto out;
+
+ if (!target->validity_meta_object) {
+ g_warning ("Internal gda_sql_statement_check_validity() error: target->validity_meta_object is not set");
+ goto out;
+ }
+
+ GSList *fields, *holders;
+ for (fields = select->expr_list, holders = GDA_SET (iter)->holders;
+ fields && holders;
+ fields = fields->next, holders = holders->next) {
+ GdaSqlSelectField *selfield = (GdaSqlSelectField*) fields->data;
+ if (selfield->validity_meta_table_column) {
+ GdaMetaTableColumn *tcol = selfield->validity_meta_table_column;
+
+ /*g_print ("==> %s\n", tcol->column_name);*/
+ gda_holder_set_not_null (GDA_HOLDER (holders->data), ! tcol->nullok);
+ if (tcol->default_value) {
+ GValue *dvalue;
+ g_value_set_string ((dvalue = gda_value_new (G_TYPE_STRING)), tcol->default_value);
+ gda_holder_set_default_value (GDA_HOLDER (holders->data), dvalue);
+ gda_value_free (dvalue);
+ }
+ }
+ else if (selfield->validity_meta_object && (selfield->validity_meta_object->obj_type == GDA_META_DB_TABLE) &&
+ selfield->expr && selfield->expr->value && !selfield->expr->param_spec &&
+ (G_VALUE_TYPE (selfield->expr->value) == G_TYPE_STRING) &&
+ !strcmp (g_value_get_string (selfield->expr->value), "*")) {
+ /* expand all the fields */
+ GdaMetaTable *mtable = GDA_META_TABLE (selfield->validity_meta_object);
+ GSList *tmplist;
+ for (tmplist = mtable->columns; tmplist; tmplist = tmplist->next) {
+ GdaMetaTableColumn *tcol = (GdaMetaTableColumn*) tmplist->data;
+ /*g_print ("*==> %s\n", tcol->column_name);*/
+ gda_holder_set_not_null (GDA_HOLDER (holders->data), ! tcol->nullok);
+ if (tcol->default_value) {
+ GValue *dvalue;
+ g_value_set_string ((dvalue = gda_value_new (G_TYPE_STRING)), tcol->default_value);
+ gda_holder_set_default_value (GDA_HOLDER (holders->data), dvalue);
+ gda_value_free (dvalue);
+ }
+ if (tmplist != mtable->columns)
+ holders = holders->next;
+ }
+ }
+ }
+ if (fields || holders)
+ g_warning ("Internal error: GdaDataModelIter has %d GdaHolders, and SELECT statement has %d expressions",
+ g_slist_length (GDA_SET (iter)->holders), g_slist_length (select->expr_list));
+
+ out:
+ gda_sql_statement_free (sqlst);
+}
static void
gda_data_model_iter_set_property (GObject *object,
@@ -390,7 +472,7 @@
g_return_if_fail (ptr && GDA_IS_DATA_MODEL (ptr));
model = GDA_DATA_MODEL (ptr);
- /* REM: model is actually set using the next property */
+ /* REM: model is actually set in the next property's code (there is no break statement) */
/* compute parameters */
ncols = gda_data_model_get_n_columns (model);
@@ -449,10 +531,23 @@
iter->priv->data_model = GDA_DATA_MODEL (ptr);
g_object_add_weak_pointer (G_OBJECT (iter->priv->data_model),
(gpointer*) &(iter->priv->data_model));
- iter->priv->model_changes_signals [0] = g_signal_connect (G_OBJECT (ptr), "row_updated",
+ iter->priv->model_changes_signals [0] = g_signal_connect (G_OBJECT (ptr), "row-updated",
G_CALLBACK (model_row_updated_cb), iter);
- iter->priv->model_changes_signals [1] = g_signal_connect (G_OBJECT (ptr), "row_removed",
+ iter->priv->model_changes_signals [1] = g_signal_connect (G_OBJECT (ptr), "row-removed",
G_CALLBACK (model_row_removed_cb), iter);
+
+ if (GDA_IS_DATA_SELECT (iter->priv->data_model)) {
+ GdaStatement *sel_stmt;
+ GdaConnection *cnc;
+ g_object_get (G_OBJECT (iter->priv->data_model), "connection", &cnc,
+ "select-stmt", &sel_stmt, NULL);
+ if (sel_stmt && cnc)
+ set_holders_properties_from_select_stmt (iter, cnc, sel_stmt);
+ if (sel_stmt)
+ g_object_unref (sel_stmt);
+ if (cnc)
+ g_object_unref (cnc);
+ }
break;
}
case PROP_CURRENT_ROW:
Modified: trunk/libgda/gda-data-model-query.c
==============================================================================
--- trunk/libgda/gda-data-model-query.c (original)
+++ trunk/libgda/gda-data-model-query.c Tue Sep 9 20:42:53 2008
@@ -206,6 +206,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = gda_data_model_query_set_value_at;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = gda_data_model_query_set_values;
iface->i_append_values = gda_data_model_query_append_values;
iface->i_append_row = NULL;
Modified: trunk/libgda/gda-data-model.c
==============================================================================
--- trunk/libgda/gda-data-model.c (original)
+++ trunk/libgda/gda-data-model.c Tue Sep 9 20:42:53 2008
@@ -110,7 +110,7 @@
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
gda_data_model_signals[ROW_INSERTED] =
- g_signal_new ("row_inserted",
+ g_signal_new ("row-inserted",
GDA_TYPE_DATA_MODEL,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaDataModelClass, row_inserted),
@@ -118,7 +118,7 @@
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
gda_data_model_signals[ROW_UPDATED] =
- g_signal_new ("row_updated",
+ g_signal_new ("row-updated",
GDA_TYPE_DATA_MODEL,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaDataModelClass, row_updated),
@@ -126,7 +126,7 @@
g_cclosure_marshal_VOID__INT,
G_TYPE_NONE, 1, G_TYPE_INT);
gda_data_model_signals[ROW_REMOVED] =
- g_signal_new ("row_removed",
+ g_signal_new ("row-removed",
GDA_TYPE_DATA_MODEL,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaDataModelClass, row_removed),
@@ -1453,15 +1453,6 @@
xmlSetProp (node, (xmlChar*)name, value ? (xmlChar*)"TRUE" : (xmlChar*)"FALSE");
}
-static void
-xml_set_int (xmlNodePtr node, const gchar *name, gint value)
-{
- char s[80];
-
- sprintf (s, "%d", value);
- xmlSetProp (node, (xmlChar*)name, (xmlChar*)s);
-}
-
/**
* gda_data_model_to_xml_node
* @model: a #GdaDataModel object.
@@ -1538,31 +1529,14 @@
cstr = gda_column_get_title (column);
if (cstr && *cstr)
xmlSetProp (field, BAD_CAST "title", BAD_CAST cstr);
- cstr = gda_column_get_caption (column);
- if (cstr && *cstr)
- xmlSetProp (field, BAD_CAST "caption", BAD_CAST cstr);
cstr = gda_column_get_dbms_type (column);
if (cstr && *cstr)
xmlSetProp (field, BAD_CAST "dbms_type", BAD_CAST cstr);
xmlSetProp (field, BAD_CAST "gdatype", BAD_CAST gda_g_type_to_string (gda_column_get_g_type (column)));
- if (gda_column_get_defined_size (column) != 0)
- xml_set_int (field, "size", gda_column_get_defined_size (column));
- if (gda_column_get_scale (column) != 0)
- xml_set_int (field, "scale", gda_column_get_scale (column));
- if (gda_column_get_primary_key (column))
- xml_set_boolean (field, "pkey", gda_column_get_primary_key (column));
- if (gda_column_get_unique_key (column))
- xml_set_boolean (field, "unique", gda_column_get_unique_key (column));
if (gda_column_get_allow_null (column))
xml_set_boolean (field, "nullok", gda_column_get_allow_null (column));
if (gda_column_get_auto_increment (column))
xml_set_boolean (field, "auto_increment", gda_column_get_auto_increment (column));
- cstr = gda_column_get_references (column);
- if (cstr && *cstr)
- xmlSetProp (field, BAD_CAST "ref", BAD_CAST cstr);
- cstr = gda_column_get_table (column);
- if (cstr && *cstr)
- xmlSetProp (field, BAD_CAST "table", BAD_CAST cstr);
}
/* add the model data to the XML output */
Modified: trunk/libgda/gda-data-model.h
==============================================================================
--- trunk/libgda/gda-data-model.h (original)
+++ trunk/libgda/gda-data-model.h Tue Sep 9 20:42:53 2008
@@ -96,6 +96,8 @@
gboolean (* i_set_value_at) (GdaDataModel *model, gint col, gint row,
const GValue *value, GError **error);
+ gboolean (* i_iter_set_value) (GdaDataModel *model, GdaDataModelIter *iter, gint col,
+ const GValue *value, GError **error);
gboolean (* i_set_values) (GdaDataModel *model, gint row, GList *values,
GError **error);
gint (* i_append_values) (GdaDataModel *model, const GList *values, GError **error);
Modified: trunk/libgda/gda-data-proxy.c
==============================================================================
--- trunk/libgda/gda-data-proxy.c (original)
+++ trunk/libgda/gda-data-proxy.c Tue Sep 9 20:42:53 2008
@@ -541,42 +541,42 @@
/* signals */
gda_data_proxy_signals [ROW_DELETE_CHANGED] =
- g_signal_new ("row_delete_changed",
+ g_signal_new ("row-delete-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaDataProxyClass, row_delete_changed),
NULL, NULL,
gda_marshal_VOID__INT_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
gda_data_proxy_signals [SAMPLE_SIZE_CHANGED] =
- g_signal_new ("sample_size_changed",
+ g_signal_new ("sample-size-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaDataProxyClass, sample_size_changed),
NULL, NULL,
g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gda_data_proxy_signals [SAMPLE_CHANGED] =
- g_signal_new ("sample_changed",
+ g_signal_new ("sample-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaDataProxyClass, sample_changed),
NULL, NULL,
gda_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
gda_data_proxy_signals [PRE_CHANGES_APPLIED] =
- g_signal_new ("pre_changes_applied",
+ g_signal_new ("pre-changes-applied",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaDataProxyClass, pre_changes_applied),
pre_changes_accumulator, NULL,
gda_marshal_BOOLEAN__INT_INT, G_TYPE_BOOLEAN, 2, G_TYPE_INT, G_TYPE_INT);
gda_data_proxy_signals [POST_CHANGES_APPLIED] =
- g_signal_new ("post_changes_applied",
+ g_signal_new ("post-changes-applied",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaDataProxyClass, post_changes_applied),
NULL, NULL,
gda_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
gda_data_proxy_signals [FILTER_CHANGED] =
- g_signal_new ("filter_changed",
+ g_signal_new ("filter-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
0, /* no associated a class method */
@@ -632,6 +632,7 @@
iface->i_iter_prev = NULL;
iface->i_set_value_at = gda_data_proxy_set_value_at;
+ iface->i_iter_set_value = NULL;
iface->i_set_values = gda_data_proxy_set_values;
iface->i_append_values = gda_data_proxy_append_values;
iface->i_append_row = gda_data_proxy_append_row;
@@ -852,11 +853,11 @@
g_value_set_flags (proxy->priv->columns_attrs[col], flags);
}
- g_signal_connect (G_OBJECT (model), "row_inserted",
+ g_signal_connect (G_OBJECT (model), "row-inserted",
G_CALLBACK (proxied_model_row_inserted_cb), proxy);
- g_signal_connect (G_OBJECT (model), "row_updated",
+ g_signal_connect (G_OBJECT (model), "row-updated",
G_CALLBACK (proxied_model_row_updated_cb), proxy);
- g_signal_connect (G_OBJECT (model), "row_removed",
+ g_signal_connect (G_OBJECT (model), "row-removed",
G_CALLBACK (proxied_model_row_removed_cb), proxy);
g_signal_connect (G_OBJECT (model), "reset",
G_CALLBACK (proxied_model_reset_cb), proxy);
@@ -1987,7 +1988,7 @@
}
else if ((proxy->priv->catched_inserted_row < 0) &&
!GDA_IS_DATA_MODEL_QUERY (proxy->priv->model)) {
- /* REM: the GdaDataModelQuery object does not emit any "row_inserted", "row_updated"
+ /* REM: the GdaDataModelQuery object does not emit any "row-inserted", "row-updated"
* or "row_dremoved" signals but that is Ok as an exception: all the other data
* model should be implemented correctly
*/
@@ -2013,7 +2014,7 @@
* should habe emitted the "row_{inserted,removed,updated}" signals */
if (rm && g_slist_find (proxy->priv->all_modifs, rm)) {
if (!GDA_IS_DATA_MODEL_QUERY (proxy->priv->model)) {
- /* REM: the GdaDataModelQuery object does not emit any "row_inserted", "row_updated"
+ /* REM: the GdaDataModelQuery object does not emit any "row-inserted", "row-updated"
* or "row_dremoved" signals but that is Ok as an exception: all the other data
* model should be implemented correctly
*/
@@ -2376,7 +2377,7 @@
g_print ("INDEX=%d step=%d max_steps=%d cur_row=%d repl_row=%d\n", index, step, max_steps, cur_row, repl_row);
#endif
if ((cur_row >= 0) && (repl_row >= 0)) {
- /* emit the GdaDataModel::"row_updated" signal */
+ /* emit the GdaDataModel::"row-updated" signal */
if (proxy->priv->chunk) {
g_array_insert_val (proxy->priv->chunk->mapping, index, repl_row);
g_array_remove_index (proxy->priv->chunk->mapping, index + 1);
@@ -2393,7 +2394,7 @@
index++;
}
else if ((cur_row >= 0) && (repl_row < 0)) {
- /* emit the GdaDataModel::"row_removed" signal */
+ /* emit the GdaDataModel::"row-removed" signal */
if (proxy->priv->chunk)
g_array_remove_index (proxy->priv->chunk->mapping, index);
proxy->priv->chunk_proxy_nb_rows--;
@@ -2405,7 +2406,7 @@
}
}
else if ((cur_row < 0) && (repl_row >= 0)) {
- /* emit GdaDataModel::"row_inserted" insert signal */
+ /* emit GdaDataModel::"row-inserted" insert signal */
if (proxy->priv->chunk)
g_array_insert_val (proxy->priv->chunk->mapping, index, repl_row);
proxy->priv->chunk_sep++;
@@ -3296,7 +3297,7 @@
else {
/* non existing row, return NULL */
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ROW_OUT_OF_RANGE_ERROR,
- _("Row %d out of range (0-%d)"), proxy_row, gda_data_model_get_n_rows (model));
+ _("Row %d out of range (0-%d)"), proxy_row, gda_data_model_get_n_rows (model) - 1);
retval = NULL;
}
}
@@ -3327,7 +3328,7 @@
else {
/* non existing row, return NULL */
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ROW_OUT_OF_RANGE_ERROR,
- _("Row %d out of range (0-%d)"), proxy_row, gda_data_model_get_n_rows (model));
+ _("Row %d out of range (0-%d)"), proxy_row, gda_data_model_get_n_rows (model) - 1);
retval = NULL;
}
}
Modified: trunk/libgda/gda-data-select.c
==============================================================================
--- trunk/libgda/gda-data-select.c (original)
+++ trunk/libgda/gda-data-select.c Tue Sep 9 20:42:53 2008
@@ -93,7 +93,8 @@
PROP_PARAMS,
PROP_INS_QUERY,
PROP_UPD_QUERY,
- PROP_DEL_QUERY
+ PROP_DEL_QUERY,
+ PROP_SEL_STMT
};
/* module error */
@@ -146,9 +147,11 @@
static gboolean gda_data_select_iter_at_row (GdaDataModel *model, GdaDataModelIter *iter, gint row);
static gboolean gda_data_select_set_value_at (GdaDataModel *model, gint col, gint row,
- const GValue *value, GError **error);
+ const GValue *value, GError **error);
+static gboolean gda_data_select_iter_set_value (GdaDataModel *model, GdaDataModelIter *iter, gint col,
+ const GValue *value, GError **error);
static gboolean gda_data_select_set_values (GdaDataModel *model, gint row, GList *values,
- GError **error);
+ GError **error);
static gint gda_data_select_append_values (GdaDataModel *model, const GList *values, GError **error);
static gboolean gda_data_select_remove_row (GdaDataModel *model, gint row, GError **error);
@@ -227,23 +230,28 @@
GDA_TYPE_SET,
G_PARAM_WRITABLE | G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_INS_QUERY,
- g_param_spec_object ("insert-stmt", "INSERT query",
- "INSERT Query to be executed to add data",
+ g_param_spec_object ("insert-stmt", "INSERT statement",
+ "INSERT Statement to be executed to add data",
GDA_TYPE_STATEMENT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class, PROP_UPD_QUERY,
- g_param_spec_object ("update-stmt", "UPDATE query",
- "UPDATE Query to be executed to update data",
+ g_param_spec_object ("update-stmt", "UPDATE statement",
+ "UPDATE Statement to be executed to update data",
GDA_TYPE_STATEMENT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (object_class, PROP_DEL_QUERY,
- g_param_spec_object ("delete-stmt", "DELETE query",
- "DELETE Query to be executed to remove data",
+ g_param_spec_object ("delete-stmt", "DELETE statement",
+ "DELETE Statement to be executed to remove data",
GDA_TYPE_STATEMENT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class, PROP_SEL_STMT,
+ g_param_spec_object ("select-stmt", "SELECT statement",
+ "SELECT statement which was executed to yield to the data model",
+ GDA_TYPE_STATEMENT, G_PARAM_READABLE));
+
/* virtual functions */
object_class->dispose = gda_data_select_dispose;
object_class->finalize = gda_data_select_finalize;
@@ -265,6 +273,7 @@
iface->i_iter_prev = gda_data_select_iter_prev;
iface->i_set_value_at = gda_data_select_set_value_at;
+ iface->i_iter_set_value = gda_data_select_iter_set_value;
iface->i_set_values = gda_data_select_set_values;
iface->i_append_values = gda_data_select_append_values;
iface->i_append_row = NULL;
@@ -599,6 +608,9 @@
case PROP_UPD_QUERY:
g_value_set_object (value, model->priv->modif_internals->modif_stmts [UPD_QUERY]);
break;
+ case PROP_SEL_STMT:
+ g_value_set_object (value, check_acceptable_statement (model, NULL));
+ break;
default:
break;
}
@@ -1472,10 +1484,17 @@
/* available only if GDA_DATA_MODEL_ACCESS_RANDOM */
if (! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
- _("Data model does not support random access"));
+ _("Data model does only support random access"));
return NULL;
}
+ if ((col >= gda_data_select_get_n_columns (model)) ||
+ (col < 0)) {
+ g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_COLUMN_OUT_OF_RANGE_ERROR,
+ _("Column %d out of range (0-%d)"), col, gda_data_select_get_n_columns (model) - 1);
+ return NULL;
+ }
+
int_row = external_to_internal_row (imodel, row, NULL);
if (int_row < 0) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ROW_OUT_OF_RANGE_ERROR,
@@ -1653,7 +1672,7 @@
return update_iter (imodel, prow);
}
else {
- g_signal_emit_by_name (iter, "end_of_data");
+ g_signal_emit_by_name (iter, "end-of-data");
g_object_set (G_OBJECT (iter), "current-row", -1, NULL);
imodel->priv->iter_row = G_MAXINT;
return FALSE;
@@ -2124,7 +2143,7 @@
* REM: @bv is stolen here
*/
static gboolean
-vector_set_value_at (GdaDataSelect *imodel, BVector *bv, gint row, GError **error)
+vector_set_value_at (GdaDataSelect *imodel, BVector *bv, GdaDataModelIter *iter, gint row, GError **error)
{
gint int_row, i, ncols;
GdaHolder *holder;
@@ -2140,9 +2159,9 @@
_("Modifications are not allowed anymore"));
return FALSE;
}
- if (! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
+ if (!iter && ! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
- _("Data model does not support random access"));
+ _("Data model does only support random access"));
return FALSE;
}
if (! imodel->priv->modif_internals->modif_stmts [UPD_QUERY]) {
@@ -2151,6 +2170,9 @@
return FALSE;
}
+ if (iter)
+ row = gda_data_model_iter_get_row (iter);
+
int_row = external_to_internal_row (imodel, row, error);
if (int_row < 0)
return FALSE;
@@ -2180,9 +2202,19 @@
g_free (str);
if (holder) {
const GValue *cvalue;
- cvalue = gda_data_model_get_value_at ((GdaDataModel*) imodel, i, int_row, error);
- if (!cvalue)
- return FALSE;
+ if (iter) {
+ cvalue = gda_data_model_iter_get_value_at (iter, i);
+ if (!cvalue) {
+ g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
+ _("Could not get iterator's value"));
+ return FALSE;
+ }
+ }
+ else {
+ cvalue = gda_data_model_get_value_at ((GdaDataModel*) imodel, i, int_row, error);
+ if (!cvalue)
+ return FALSE;
+ }
if (! gda_holder_set_value (holder, cvalue, error))
return FALSE;
@@ -2296,7 +2328,68 @@
}
if (! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
- _("Data model does not support random access"));
+ _("Data model does only support random access"));
+ return FALSE;
+ }
+ if (! imodel->priv->modif_internals->modif_stmts [UPD_QUERY]) {
+ g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
+ _("No UPDATE statement provided"));
+ return FALSE;
+ }
+
+ /* arguments check */
+ ncols = gda_data_select_get_n_columns (model);
+ if (col >= ncols) {
+ g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
+ _("Column %d out of range (0-%d)"), col, ncols-1);
+ return FALSE;
+ }
+
+ /* invalidate all the imodel->priv->modif_internals->modif_set's value holders */
+ GSList *list;
+ for (list = imodel->priv->modif_internals->modif_set->holders; list; list = list->next) {
+ GdaHolder *h = (GdaHolder*) list->data;
+ if (param_name_to_int (gda_holder_get_id (h), NULL, NULL))
+ gda_holder_force_invalid ((GdaHolder*) list->data);
+ }
+
+ /* give values to params for new value */
+ str = g_strdup_printf ("+%d", col);
+ holder = gda_set_get_holder (imodel->priv->modif_internals->modif_set, str);
+ g_free (str);
+ if (! holder) {
+ g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR,
+ _("Column %d can't be modified"), col);
+ return FALSE;
+ }
+ if (! gda_holder_set_value (holder, value, error))
+ return FALSE;
+
+ /* BVector */
+ BVector *bv;
+ bv = g_new (BVector, 1);
+ bv->size = col + 1;
+ bv->data = g_new0 (guchar, bv->size);
+ bv->data[col] = 1;
+
+ return vector_set_value_at (imodel, bv, NULL, row, error);
+}
+
+static gboolean
+gda_data_select_iter_set_value (GdaDataModel *model, GdaDataModelIter *iter, gint col,
+ const GValue *value, GError **error)
+{
+ GdaDataSelect *imodel;
+ gint ncols;
+ GdaHolder *holder;
+ gchar *str;
+
+ imodel = (GdaDataSelect *) model;
+ g_return_val_if_fail (imodel->priv, FALSE);
+
+ if (imodel->priv->modif_internals->safely_locked) {
+ g_set_error (error, GDA_DATA_SELECT_ERROR, GDA_DATA_SELECT_SAFETY_LOCKED_ERROR,
+ _("Modifications are not allowed anymore"));
return FALSE;
}
if (! imodel->priv->modif_internals->modif_stmts [UPD_QUERY]) {
@@ -2340,7 +2433,7 @@
bv->data = g_new0 (guchar, bv->size);
bv->data[col] = 1;
- return vector_set_value_at (imodel, bv, row, error);
+ return vector_set_value_at (imodel, bv, iter, G_MININT, error);
}
static void
@@ -2376,7 +2469,7 @@
}
if (! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
- _("Data model does not support random access"));
+ _("Data model does only support random access"));
return FALSE;
}
if (! imodel->priv->modif_internals->modif_stmts [UPD_QUERY]) {
@@ -2440,7 +2533,7 @@
}
}
- return vector_set_value_at (imodel, bv, row, error);
+ return vector_set_value_at (imodel, bv, NULL, row, error);
}
static gint
@@ -2463,7 +2556,7 @@
}
if (! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
- _("Data model does not support random access"));
+ _("Data model does only support random access"));
return -1;
}
if (! imodel->priv->modif_internals->modif_stmts [INS_QUERY]) {
@@ -2646,7 +2739,7 @@
}
if (! (imodel->priv->usage_flags & GDA_DATA_MODEL_ACCESS_RANDOM)) {
g_set_error (error, GDA_DATA_MODEL_ERROR, GDA_DATA_MODEL_ACCESS_ERROR,
- _("Data model does not support random access"));
+ _("Data model does only support random access"));
return FALSE;
}
if (! imodel->priv->modif_internals->modif_stmts [DEL_QUERY]) {
Modified: trunk/libgda/gda-holder.c
==============================================================================
--- trunk/libgda/gda-holder.c (original)
+++ trunk/libgda/gda-holder.c Tue Sep 9 20:42:53 2008
@@ -57,10 +57,11 @@
{
CHANGED,
SOURCE_CHANGED,
+ BEFORE_CHANGE,
LAST_SIGNAL
};
-static gint gda_holder_signals[LAST_SIGNAL] = { 0, 0 };
+static gint gda_holder_signals[LAST_SIGNAL] = { 0, 0, 0 };
/* properties */
@@ -141,6 +142,26 @@
return type;
}
+static gboolean
+before_change_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer data)
+{
+ GError *error;
+
+ error = g_value_get_pointer (handler_return);
+ g_value_set_pointer (return_accu, error);
+
+ return error ? FALSE : TRUE; /* stop signal if 'thisvalue' is FALSE */
+}
+
+static GError *
+m_before_change (GdaHolder *holder, const GValue *new_value)
+{
+ return NULL;
+}
+
static void
gda_holder_class_init (GdaHolderClass *class)
{
@@ -149,7 +170,7 @@
parent_class = g_type_class_peek_parent (class);
gda_holder_signals[SOURCE_CHANGED] =
- g_signal_new ("source_changed",
+ g_signal_new ("source-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaHolderClass, source_changed),
@@ -162,9 +183,28 @@
G_STRUCT_OFFSET (GdaHolderClass, changed),
NULL, NULL,
gda_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ /**
+ * GdaHolder::before-change:
+ * @holder: the object which received the signal
+ * @new_value: the proposed new value for @holder
+ *
+ * Gets emitted when @holder is going to change its value. One can connect to
+ * this signal to control which values @holder can have (for example to implement some business rules)
+ *
+ * Return value: NULL if @holder is allowed to change its value to @new_value, or a #GError
+ * otherwise.
+ */
+ gda_holder_signals[BEFORE_CHANGE] =
+ g_signal_new ("before-change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdaHolderClass, before_change),
+ before_change_accumulator, NULL,
+ gda_marshal_POINTER__POINTER, G_TYPE_POINTER, 1, G_TYPE_POINTER);
class->changed = NULL;
class->source_changed = NULL;
+ class->before_change = m_before_change;
/* virtual functions */
object_class->dispose = gda_holder_dispose;
@@ -700,8 +740,8 @@
* Sets the value within the holder. If @holder is an alias for another
* holder, then the value is also set for that other holder.
*
- * The action of any call to gda_holder_force_invalid() is cancelled
- * as soon as this method is called, even if @holder's value does not change.
+ * On success, the action of any call to gda_holder_force_invalid() is cancelled
+ * as soon as this method is called (even if @holder's value does not actually change)
*
* If the value is not different from the one already contained within @holder,
* then @holder is not changed and no signal is emitted.
@@ -711,6 +751,10 @@
* Note2: if @holder can't accept the @value value, then this method returns FALSE, and @holder will be left
* in an invalid state.
*
+ * Note3: before the change is accepted by @holder, the "before-change" signal will be emitted (the value
+ * of which can prevent the change from happening) which can be connected to to have a greater control
+ * of which values @holder can have, or implement some business rules.
+ *
* Returns: TRUE if value has been set
*/
gboolean
@@ -776,15 +820,19 @@
* Sets the value within the holder. If @holder is an alias for another
* holder, then the value is also set for that other holder.
*
- * The action of any call to gda_holder_force_invalid() is cancelled
- * as soon as this method is called, even if @holder's value does not change.
+ * On success, the action of any call to gda_holder_force_invalid() is cancelled
+ * as soon as this method is called (even if @holder's value does not actually change).
*
* If the value is not different from the one already contained within @holder,
* then @holder is not chaged and no signal is emitted.
*
- * Note: if @holder can't accept the @value value, then this method returns FALSE, and @holder will be left
+ * Note1: if @holder can't accept the @value value, then this method returns FALSE, and @holder will be left
* in an invalid state.
*
+ * Note2: before the change is accepted by @holder, the "before-change" signal will be emitted (the value
+ * of which can prevent the change from happening) which can be connected to to have a greater control
+ * of which values @holder can have, or implement some business rules.
+ *
* Returns: TRUE if value has been set
*/
gboolean
@@ -810,8 +858,6 @@
gboolean was_valid = gda_holder_is_valid (holder);
#endif
- holder->priv->invalid_forced = FALSE;
-
/* holder will be changed? */
newnull = !value || gda_value_is_null (value);
current_val = gda_holder_get_value (holder);
@@ -854,9 +900,23 @@
if (!changed) {
if (!do_copy && value)
gda_value_free (value);
+ holder->priv->invalid_forced = FALSE;
return TRUE;
}
+ /* check if we are allowed to change value */
+ GError *lerror = NULL;
+ g_signal_emit (holder, gda_holder_signals[BEFORE_CHANGE], 0, value, &lerror);
+ if (lerror) {
+ /* change refused by signal callback */
+ g_propagate_error (error, lerror);
+ if (!do_copy)
+ gda_value_free (value);
+ return FALSE;
+ }
+
+ /* new valid status */
+ holder->priv->invalid_forced = FALSE;
holder->priv->valid = newvalid;
/* check is the new value is the default one */
Modified: trunk/libgda/gda-holder.h
==============================================================================
--- trunk/libgda/gda-holder.h (original)
+++ trunk/libgda/gda-holder.h Tue Sep 9 20:42:53 2008
@@ -56,6 +56,7 @@
GObjectClass parent_class;
void (*changed) (GdaHolder *holder);
void (*source_changed) (GdaHolder *holder);
+ GError *(*before_change) (GdaHolder *holder, const GValue *new_value);
};
GType gda_holder_get_type (void) G_GNUC_CONST;
Modified: trunk/libgda/gda-marshal.list
==============================================================================
--- trunk/libgda/gda-marshal.list (original)
+++ trunk/libgda/gda-marshal.list Tue Sep 9 20:42:53 2008
@@ -42,3 +42,4 @@
BOOLEAN:INT,INT
POINTER:POINTER
BOOLEAN:POINTER
+POINTER:OBJECT,POINTER
Modified: trunk/libgda/gda-meta-store.c
==============================================================================
--- trunk/libgda/gda-meta-store.c (original)
+++ trunk/libgda/gda-meta-store.c Tue Sep 9 20:42:53 2008
@@ -346,7 +346,7 @@
* signal, or %NULL if signal propagation should continue
**/
gda_meta_store_signals[SUGGEST_UPDATE] =
- g_signal_new ("suggest_update",
+ g_signal_new ("suggest-update",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdaMetaStoreClass, suggest_update),
@@ -354,7 +354,7 @@
gda_marshal_POINTER__POINTER, G_TYPE_POINTER,
1, G_TYPE_POINTER);
gda_meta_store_signals[META_CHANGED] =
- g_signal_new ("meta_changed",
+ g_signal_new ("meta-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaMetaStoreClass, meta_changed),
@@ -362,7 +362,7 @@
gda_marshal_VOID__POINTER, G_TYPE_NONE,
1, G_TYPE_POINTER);
gda_meta_store_signals[META_RESET] =
- g_signal_new ("meta_reset",
+ g_signal_new ("meta-reset",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaMetaStoreClass, meta_reset),
Modified: trunk/libgda/gda-meta-struct-io.c
==============================================================================
--- trunk/libgda/gda-meta-struct-io.c (original)
+++ trunk/libgda/gda-meta-struct-io.c Tue Sep 9 20:42:53 2008
@@ -298,7 +298,7 @@
/* referenced GdaMetaDbObject */
GdaMetaDbObject *ref_obj;
gchar *name_part, *schema_part, *catalog_part = NULL;
- gchar *tmp = g_strdup (ref_table);
+ gchar *tmp = g_strdup ((gchar *) ref_table);
if (!_split_identifier_string (tmp, &schema_part, &name_part)) {
g_set_error (error, GDA_META_STRUCT_ERROR, 0, /* FIXME */
_("Invalid referenced table name '%s'"), ref_table);
Modified: trunk/libgda/gda-meta-struct.c
==============================================================================
--- trunk/libgda/gda-meta-struct.c (original)
+++ trunk/libgda/gda-meta-struct.c Tue Sep 9 20:42:53 2008
@@ -225,9 +225,9 @@
mstruct->priv->store = g_value_get_object (value);
if (mstruct->priv->store) {
g_object_ref (mstruct->priv->store);
- g_signal_connect (G_OBJECT (mstruct->priv->store), "meta_changed",
+ g_signal_connect (G_OBJECT (mstruct->priv->store), "meta-changed",
G_CALLBACK (meta_store_changed_cb), mstruct);
- g_signal_connect (G_OBJECT (mstruct->priv->store), "meta_reset",
+ g_signal_connect (G_OBJECT (mstruct->priv->store), "meta-reset",
G_CALLBACK (meta_store_reset_cb), mstruct);
}
break;
Modified: trunk/libgda/gda-server-operation.c
==============================================================================
--- trunk/libgda/gda-server-operation.c (original)
+++ trunk/libgda/gda-server-operation.c Tue Sep 9 20:42:53 2008
@@ -139,7 +139,7 @@
/* signals */
gda_server_operation_signals[SEQUENCE_ITEM_ADDED] =
- g_signal_new ("sequence_item_added",
+ g_signal_new ("sequence-item-added",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaServerOperationClass, seq_item_added),
@@ -147,7 +147,7 @@
gda_marshal_VOID__STRING_INT, G_TYPE_NONE,
2, G_TYPE_STRING, G_TYPE_INT);
gda_server_operation_signals[SEQUENCE_ITEM_REMOVE] =
- g_signal_new ("sequence_item_remove",
+ g_signal_new ("sequence-item-remove",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaServerOperationClass, seq_item_remove),
Modified: trunk/libgda/gda-set.c
==============================================================================
--- trunk/libgda/gda-set.c (original)
+++ trunk/libgda/gda-set.c Tue Sep 9 20:42:53 2008
@@ -51,6 +51,7 @@
static void set_remove_source (GdaSet *set, GdaSetSource *source);
static void changed_holder_cb (GdaHolder *holder, GdaSet *dataset);
+static GError *before_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *dataset);
static void source_changed_holder_cb (GdaHolder *holder, GdaSet *dataset);
static void notify_holder_cb (GdaHolder *holder, GParamSpec *pspec, GdaSet *dataset);
@@ -77,10 +78,11 @@
PUBLIC_DATA_CHANGED,
HOLDER_PLUGIN_CHANGED,
HOLDER_ATTR_CHANGED,
+ BEFORE_HOLDER_CHANGE,
LAST_SIGNAL
};
-static gint gda_set_signals[LAST_SIGNAL] = { 0, 0, 0, 0 };
+static gint gda_set_signals[LAST_SIGNAL] = { 0, 0, 0, 0, 0 };
/* private structure */
@@ -194,6 +196,25 @@
return type;
}
+static gboolean
+before_holder_change_accumulator (GSignalInvocationHint *ihint,
+ GValue *return_accu,
+ const GValue *handler_return,
+ gpointer data)
+{
+ GError *error;
+
+ error = g_value_get_pointer (handler_return);
+ g_value_set_pointer (return_accu, error);
+
+ return error ? FALSE : TRUE; /* stop signal if 'thisvalue' is FALSE */
+}
+
+static GError *
+m_before_holder_change (GdaSet *set, GdaHolder *holder, const GValue *new_value)
+{
+ return NULL;
+}
static void
gda_set_class_init (GdaSetClass *class)
@@ -203,15 +224,36 @@
parent_class = g_type_class_peek_parent (class);
gda_set_signals[HOLDER_CHANGED] =
- g_signal_new ("holder_changed",
+ g_signal_new ("holder-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaSetClass, holder_changed),
NULL, NULL,
gda_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GDA_TYPE_HOLDER);
+
+ /**
+ * GdaSet::before-holder-change:
+ * @set: the object which received the signal
+ * @holder: the #GdaHolder which is going to change
+ * @new_value: the proposed new value for @holder
+ *
+ * Gets emitted when a #GdaHolder's in @set is going to change its value. One can connect to
+ * this signal to control which values @holder can have (for example to implement some business rules)
+ *
+ * Return value: NULL if @holder is allowed to change its value to @new_value, or a #GError
+ * otherwise.
+ */
+ gda_set_signals[BEFORE_HOLDER_CHANGE] =
+ g_signal_new ("before-holder-change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GdaSetClass, before_holder_change),
+ before_holder_change_accumulator, NULL,
+ gda_marshal_POINTER__OBJECT_POINTER, G_TYPE_POINTER, 2,
+ GDA_TYPE_HOLDER, G_TYPE_POINTER);
gda_set_signals[HOLDER_PLUGIN_CHANGED] =
- g_signal_new ("holder_plugin_changed",
+ g_signal_new ("holder-plugin-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaSetClass, holder_plugin_changed),
@@ -219,7 +261,7 @@
gda_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GDA_TYPE_HOLDER);
gda_set_signals[HOLDER_ATTR_CHANGED] =
- g_signal_new ("holder_attr_changed",
+ g_signal_new ("holder-attr-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaSetClass, holder_attr_changed),
@@ -227,7 +269,7 @@
gda_marshal_VOID__OBJECT, G_TYPE_NONE, 1,
GDA_TYPE_HOLDER);
gda_set_signals[PUBLIC_DATA_CHANGED] =
- g_signal_new ("public_data_changed",
+ g_signal_new ("public-data-changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GdaSetClass, public_data_changed),
@@ -235,6 +277,7 @@
gda_marshal_VOID__VOID, G_TYPE_NONE, 0);
class->holder_changed = NULL;
+ class->before_holder_change = m_before_holder_change;
class->holder_plugin_changed = NULL;
class->holder_attr_changed = NULL;
class->public_data_changed = NULL;
@@ -447,7 +490,8 @@
holder = gda_set_get_holder (set, holder_id);
if (!holder) {
- g_warning (_("GdaHolder with ID '%s' not found in set"), holder_id);
+ g_set_error (error, GDA_SET_ERROR, GDA_SET_HOLDER_NOT_FOUND_ERROR,
+ _("GdaHolder with ID '%s' not found in set"), holder_id);
return FALSE;
}
type = gda_holder_get_g_type (holder);
@@ -881,6 +925,8 @@
g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
+ G_CALLBACK (before_change_holder_cb), set);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
G_CALLBACK (source_changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (holder),
G_CALLBACK (notify_holder_cb), set);
@@ -933,6 +979,21 @@
}
}
+static GError *
+before_change_holder_cb (GdaHolder *holder, const GValue *value, GdaSet *set)
+{
+ /* signal the holder before-change */
+ GError *error = NULL;
+#ifdef GDA_DEBUG_signal
+ g_print (">> 'BEFORE_HOLDER_CHANGE' from %s\n", __FUNCTION__);
+#endif
+ g_signal_emit (G_OBJECT (set), gda_set_signals[BEFORE_HOLDER_CHANGE], 0, holder, value, &error);
+#ifdef GDA_DEBUG_signal
+ g_print ("<< 'BEFORE_HOLDER_CHANGED' from %s\n", __FUNCTION__);
+#endif
+ return error;
+}
+
static void
changed_holder_cb (GdaHolder *holder, GdaSet *set)
{
@@ -969,6 +1030,8 @@
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
G_CALLBACK (changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
+ G_CALLBACK (before_change_holder_cb), set);
+ g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
G_CALLBACK (source_changed_holder_cb), set);
g_signal_handlers_disconnect_by_func (G_OBJECT (list->data),
G_CALLBACK (notify_holder_cb), set);
@@ -1269,7 +1332,9 @@
g_object_ref (holder);
g_signal_connect (G_OBJECT (holder), "changed",
G_CALLBACK (changed_holder_cb), set);
- g_signal_connect (G_OBJECT (holder), "source_changed",
+ g_signal_connect (G_OBJECT (holder), "before-change",
+ G_CALLBACK (before_change_holder_cb), set);
+ g_signal_connect (G_OBJECT (holder), "source-changed",
G_CALLBACK (source_changed_holder_cb), set);
g_signal_connect (G_OBJECT (holder), "notify",
G_CALLBACK (notify_holder_cb), set);
Modified: trunk/libgda/gda-set.h
==============================================================================
--- trunk/libgda/gda-set.h (original)
+++ trunk/libgda/gda-set.h Tue Sep 9 20:42:53 2008
@@ -39,7 +39,8 @@
typedef enum
{
- GDA_SET_XML_SPEC_ERROR
+ GDA_SET_XML_SPEC_ERROR,
+ GDA_SET_HOLDER_NOT_FOUND_ERROR
} GdaSetError;
typedef enum {
@@ -116,6 +117,7 @@
{
GObjectClass parent_class;
+ GError *(*before_holder_change) (GdaSet *set, GdaHolder *holder, const GValue *new_value);
void (*holder_changed) (GdaSet *set, GdaHolder *holder);
void (*holder_plugin_changed) (GdaSet *set, GdaHolder *holder);
void (*holder_attr_changed) (GdaSet *set, GdaHolder *holder);
Modified: trunk/libgda/gda-util.c
==============================================================================
--- trunk/libgda/gda-util.c (original)
+++ trunk/libgda/gda-util.c Tue Sep 9 20:42:53 2008
@@ -695,9 +695,12 @@
GdaSqlSelectField *sfield = NULL;
GdaMetaTableColumn *tcol;
GSList *list;
+ gint index;
tcol = (GdaMetaTableColumn *) g_slist_nth_data (mtable->columns, mtable->pk_cols_array[i]);
- for (list = stsel->expr_list; list; list = list->next) {
+ for (index = 0, list = stsel->expr_list;
+ list;
+ index++, list = list->next) {
sfield = (GdaSqlSelectField *) list->data;
if (sfield->validity_meta_table_column == tcol)
break;
@@ -729,7 +732,7 @@
/* right operand */
opexpr = gda_sql_expr_new (GDA_SQL_ANY_PART (op));
pspec = g_new0 (GdaSqlParamSpec, 1);
- pspec->name = g_strdup_printf ("-%d", mtable->pk_cols_array[i]);
+ pspec->name = g_strdup_printf ("-%d", index);
pspec->g_type = tcol->gtype != G_TYPE_INVALID ? tcol->gtype: G_TYPE_STRING;
pspec->nullok = tcol->nullok;
opexpr->param_spec = pspec;
Modified: trunk/libgda/gda-xa-transaction.c
==============================================================================
--- trunk/libgda/gda-xa-transaction.c (original)
+++ trunk/libgda/gda-xa-transaction.c Tue Sep 9 20:42:53 2008
@@ -282,7 +282,7 @@
const GdaBinary *ebranch = g_hash_table_lookup (xa_trans->priv->cnc_hash, cnc);
if (ebranch) {
bin = g_new0 (GdaBinary, 1);
- bin->data = g_strdup (branch);
+ bin->data = (guchar*) g_strdup (branch);
bin->binary_length = strlen (branch) + 1;
g_hash_table_insert (xa_trans->priv->cnc_hash, cnc, bin);
return TRUE;
@@ -314,7 +314,7 @@
bin = g_new0 (GdaBinary, 1);
- bin->data = g_strdup (branch);
+ bin->data = (guchar*) g_strdup (branch);
bin->binary_length = strlen (branch) + 1;
xa_trans->priv->cnc_list = g_list_prepend (xa_trans->priv->cnc_list, cnc);
g_hash_table_insert (xa_trans->priv->cnc_hash, cnc, bin);
Modified: trunk/libgda/sql-parser/gda-statement-struct.c
==============================================================================
--- trunk/libgda/sql-parser/gda-statement-struct.c (original)
+++ trunk/libgda/sql-parser/gda-statement-struct.c Tue Sep 9 20:42:53 2008
@@ -266,7 +266,7 @@
* If @cnc is %NULL, then remove any information from a previous call to this method stored in @stmt. In this case,
* the @stmt->validity_meta_struct attribute is cleared.
*
- * Also note that some parts of @stmt may be modified: for example leading ad trailing spaces in aliases or
+ * Also note that some parts of @stmt may be modified: for example leading and trailing spaces in aliases or
* objects names will be removed.
*
* Returns: TRUE if no error occurred
Modified: trunk/libgda/sqlite/gda-sqlite-provider.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-provider.c (original)
+++ trunk/libgda/sqlite/gda-sqlite-provider.c Tue Sep 9 20:42:53 2008
@@ -2084,6 +2084,8 @@
if (model_usage & GDA_STATEMENT_MODEL_RANDOM_ACCESS)
flags = GDA_DATA_MODEL_ACCESS_RANDOM;
+ else if (model_usage & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD)
+ flags = GDA_DATA_MODEL_ACCESS_RANDOM;
else
flags = GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD;
Modified: trunk/libgda/sqlite/gda-sqlite-recordset.c
==============================================================================
--- trunk/libgda/sqlite/gda-sqlite-recordset.c (original)
+++ trunk/libgda/sqlite/gda-sqlite-recordset.c Tue Sep 9 20:42:53 2008
@@ -233,58 +233,20 @@
i < GDA_PSTMT (ps)->ncols;
i++, list = list->next) {
GdaColumn *column;
- const char *tablename, *colname, *ctype;
- int notnull, autoinc, pkey;
column = GDA_COLUMN (list->data);
gda_column_set_title (column, sqlite3_column_name (ps->sqlite_stmt, i));
gda_column_set_name (column, sqlite3_column_name (ps->sqlite_stmt, i));
-
- tablename = sqlite3_column_table_name (ps->sqlite_stmt, i);
- colname = sqlite3_column_origin_name (ps->sqlite_stmt, i);
- if (!tablename || !colname ||
- (sqlite3_table_column_metadata (cdata->connection, NULL, tablename, colname, NULL, NULL,
- ¬null, &pkey, &autoinc) != SQLITE_OK)) {
- notnull = FALSE;
- autoinc = FALSE;
- pkey = FALSE;
- }
- gda_column_set_scale (column, -1);
- gda_column_set_defined_size (column, -1);
- gda_column_set_primary_key (column, pkey);
- gda_column_set_unique_key (column, pkey);
- gda_column_set_allow_null (column, !(pkey || notnull)); /* PK fields can't be NULL */
- gda_column_set_auto_increment (column, autoinc);
- /*g_print (".. %d pkey=>%d autoinc=>%d notnull=>%d\n", i, pkey, autoinc, notnull);*/
-
- ctype = sqlite3_column_decltype (ps->sqlite_stmt, i);
- if (ctype) {
- gchar *start, *end;
- for (start = (gchar *) ctype; *start && (*start != '('); start++);
- if (*start == '(') {
- for (end = start+1; *end && (*end != ')'); end++);
- if (*end == ')') {
- gchar *copy = g_strdup (start + 1);
- copy[end - start] = 0;
- for (start = copy; *start && (*start != ','); start++);
- if (*start != 0) {
- *start = 0;
- gda_column_set_defined_size (column, atoi (copy));
- gda_column_set_scale (column, atoi (start+1));
- }
- else
- gda_column_set_defined_size (column, atoi (copy));
-
- g_free (copy);
- }
- }
- }
+ gda_column_set_dbms_type (column, sqlite3_column_decltype (ps->sqlite_stmt, i));
}
}
- /* determine access mode: RANDOM or CURSOR FORWARD are the only supported */
+ /* determine access mode: RANDOM or CURSOR FORWARD are the only supported; if CURSOR BACKWARD
+ * is requested, then we need RANDOM mode */
if (flags & GDA_DATA_MODEL_ACCESS_RANDOM)
rflags = GDA_DATA_MODEL_ACCESS_RANDOM;
+ else if (flags & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD)
+ rflags = GDA_DATA_MODEL_ACCESS_RANDOM;
else
rflags = GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD;
Modified: trunk/libgda/sqlite/virtual/gda-vconnection-hub.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-vconnection-hub.c (original)
+++ trunk/libgda/sqlite/virtual/gda-vconnection-hub.c Tue Sep 9 20:42:53 2008
@@ -462,7 +462,7 @@
g_object_unref (model);
/* monitor changes */
- g_signal_connect (store, "meta_changed", G_CALLBACK (meta_changed_cb), hc);
+ g_signal_connect (store, "meta-changed", G_CALLBACK (meta_changed_cb), hc);
hub->priv->hub_connections = g_slist_append (hub->priv->hub_connections, hc);
return TRUE;
Modified: trunk/libgda/sqlite/virtual/gda-virtual-connection.c
==============================================================================
--- trunk/libgda/sqlite/virtual/gda-virtual-connection.c (original)
+++ trunk/libgda/sqlite/virtual/gda-virtual-connection.c Tue Sep 9 20:42:53 2008
@@ -25,6 +25,7 @@
#include <string.h>
#include <sqlite3.h>
#include "gda-virtual-connection.h"
+#include <gda-connection-private.h>
#define PARENT_TYPE GDA_TYPE_CONNECTION
#define CLASS(obj) (GDA_VIRTUAL_CONNECTION_CLASS (G_OBJECT_GET_CLASS (obj)))
Modified: trunk/providers/mdb/gda-mdb-provider.c
==============================================================================
--- trunk/providers/mdb/gda-mdb-provider.c (original)
+++ trunk/providers/mdb/gda-mdb-provider.c Tue Sep 9 20:42:53 2008
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <glib/gbacktrace.h>
#include <virtual/gda-vconnection-data-model.h>
+#include <libgda/gda-connection-private.h>
#include <libgda/gda-server-provider-extra.h>
#include <libgda/gda-data-model-array.h>
#include <libgda/gda-data-model-private.h>
@@ -409,7 +410,6 @@
mdb_col->col_type)));
gda_column_set_dbms_type (gda_col, tmp);
g_free (tmp);
- gda_column_set_defined_size (gda_col, mdb_col->col_size);
columns = g_list_prepend (columns, gda_col);
}
@@ -463,7 +463,6 @@
tmp = sanitize_name (g_strdup (mdb_col->name));
gda_column_set_name (gda_col, tmp);
gda_column_set_title (gda_col, tmp);
- gda_column_set_caption (gda_col, tmp);
g_free (tmp);
tmp = sanitize_name (g_strdup (mdb_get_coltype_string (spec->cdata->mdb->default_backend, mdb_col->col_type)));
gda_column_set_dbms_type (gda_col, tmp);
Modified: trunk/providers/mysql/gda-mysql-recordset.c
==============================================================================
--- trunk/providers/mysql/gda-mysql-recordset.c (original)
+++ trunk/providers/mysql/gda-mysql-recordset.c Tue Sep 9 20:42:53 2008
@@ -378,20 +378,6 @@
gda_column_set_g_type (column, gtype);
gda_column_set_name (column, field->name);
gda_column_set_title (column, field->name);
- gda_column_set_scale (column, (gtype == G_TYPE_DOUBLE) ? DBL_DIG :
- (gtype == G_TYPE_FLOAT) ? FLT_DIG : 0);
- gda_column_set_defined_size (column, field->length);
- gda_column_set_references (column, "");
-
- /* Use @cnc's associate GdaMetaStore to get the following information:
- gda_column_set_references (column, ...);
- gda_column_set_table (column, ...);
- gda_column_set_primary_key (column, ...);
- gda_column_set_unique_key (column, ...);
- gda_column_set_allow_null (column, ...);
- gda_column_set_auto_increment (column, ...);
- */
-
mysql_bind_result[i].buffer_type = field->type;
switch (mysql_bind_result[i].buffer_type) {
Modified: trunk/providers/postgres/gda-postgres-recordset.c
==============================================================================
--- trunk/providers/postgres/gda-postgres-recordset.c (original)
+++ trunk/providers/postgres/gda-postgres-recordset.c Tue Sep 9 20:42:53 2008
@@ -302,20 +302,6 @@
gda_column_set_g_type (column, gtype);
gda_column_set_name (column, PQfname (pg_res, i));
gda_column_set_title (column, PQfname (pg_res, i));
- gda_column_set_scale (column, (gtype == G_TYPE_DOUBLE) ? DBL_DIG :
- (gtype == G_TYPE_FLOAT) ? FLT_DIG : 0);
- gda_column_set_defined_size (column, PQfsize (pg_res, i));
- gda_column_set_references (column, "");
-
- /*
- FIXME: Use @cnc's associated GdaMetaStore to get the following information:
- gda_column_set_references (column, "");
- gda_column_set_table (column, ...);
- gda_column_set_primary_key (column, ...);
- gda_column_set_unique_key (column, ...);
- gda_column_set_allow_null (column, ...);
- gda_column_set_auto_increment (column, ...);
- */
}
}
}
Modified: trunk/tests/data-models/check_data_proxy.c
==============================================================================
--- trunk/tests/data-models/check_data_proxy.c (original)
+++ trunk/tests/data-models/check_data_proxy.c Tue Sep 9 20:42:53 2008
@@ -299,11 +299,11 @@
g_signal_connect (G_OBJECT (proxy), "reset",
G_CALLBACK (proxy_reset_cb), NULL);
- g_signal_connect (G_OBJECT (proxy), "row_inserted",
+ g_signal_connect (G_OBJECT (proxy), "row-inserted",
G_CALLBACK (proxy_row_cb), "I");
- g_signal_connect (G_OBJECT (proxy), "row_updated",
+ g_signal_connect (G_OBJECT (proxy), "row-updated",
G_CALLBACK (proxy_row_cb), "U");
- g_signal_connect (G_OBJECT (proxy), "row_removed",
+ g_signal_connect (G_OBJECT (proxy), "row-removed",
G_CALLBACK (proxy_row_cb), "R");
/*
@@ -398,11 +398,11 @@
g_signal_connect (G_OBJECT (proxy), "reset",
G_CALLBACK (proxy_reset_cb), NULL);
- g_signal_connect (G_OBJECT (proxy), "row_inserted",
+ g_signal_connect (G_OBJECT (proxy), "row-inserted",
G_CALLBACK (proxy_row_cb), "I");
- g_signal_connect (G_OBJECT (proxy), "row_updated",
+ g_signal_connect (G_OBJECT (proxy), "row-updated",
G_CALLBACK (proxy_row_cb), "U");
- g_signal_connect (G_OBJECT (proxy), "row_removed",
+ g_signal_connect (G_OBJECT (proxy), "row-removed",
G_CALLBACK (proxy_row_cb), "R");
@@ -548,11 +548,11 @@
"prepend-null-entry", prepend_null_row, NULL);
g_signal_connect (G_OBJECT (proxy), "reset",
G_CALLBACK (proxy_reset_cb), NULL);
- g_signal_connect (G_OBJECT (proxy), "row_inserted",
+ g_signal_connect (G_OBJECT (proxy), "row-inserted",
G_CALLBACK (proxy_row_cb), "I");
- g_signal_connect (G_OBJECT (proxy), "row_updated",
+ g_signal_connect (G_OBJECT (proxy), "row-updated",
G_CALLBACK (proxy_row_cb), "U");
- g_signal_connect (G_OBJECT (proxy), "row_removed",
+ g_signal_connect (G_OBJECT (proxy), "row-removed",
G_CALLBACK (proxy_row_cb), "R");
/*
@@ -670,11 +670,11 @@
g_signal_connect (G_OBJECT (proxy), "reset",
G_CALLBACK (proxy_reset_cb), NULL);
- g_signal_connect (G_OBJECT (proxy), "row_inserted",
+ g_signal_connect (G_OBJECT (proxy), "row-inserted",
G_CALLBACK (proxy_row_cb), "I");
- g_signal_connect (G_OBJECT (proxy), "row_updated",
+ g_signal_connect (G_OBJECT (proxy), "row-updated",
G_CALLBACK (proxy_row_cb), "U");
- g_signal_connect (G_OBJECT (proxy), "row_removed",
+ g_signal_connect (G_OBJECT (proxy), "row-removed",
G_CALLBACK (proxy_row_cb), "R");
/*
Modified: trunk/tests/data-models/check_pmodel.c
==============================================================================
--- trunk/tests/data-models/check_pmodel.c (original)
+++ trunk/tests/data-models/check_pmodel.c Tue Sep 9 20:42:53 2008
@@ -53,6 +53,10 @@
static gint test8 (GdaConnection *cnc);
static gint test9 (GdaConnection *cnc);
static gint test10 (GdaConnection *cnc);
+static gint test11 (GdaConnection *cnc);
+static gint test12 (GdaConnection *cnc);
+static gint test13 (GdaConnection *cnc);
+static gint test14 (GdaConnection *cnc);
TestFunc tests[] = {
test1,
@@ -64,7 +68,11 @@
test7,
test8,
test9,
- test10
+ test10,
+ test11,
+ test12,
+ test13,
+ test14
};
int
@@ -1096,6 +1104,407 @@
return nfailed;
}
+/*
+ * Reading using an iterator
+ *
+ * Returns the number of failures
+ */
+static gint
+test11 (GdaConnection *cnc)
+{
+ GError *error = NULL;
+ GdaDataModel *ramodel, *model;
+ GdaStatement *stmt;
+ gint nfailed = 0;
+ GdaSet *params;
+ GdaDataModelIter *iter;
+ gint ncols, nrows;
+
+ clear_signals ();
+
+ /* create GdaDataSelect */
+ stmt = stmt_from_string ("SELECT name, last_update, id FROM customers WHERE id <= ##id::int");
+ if (!gda_statement_get_parameters (stmt, ¶ms, &error)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Could not get SELECT's parameters!\n");
+#endif
+ goto out;
+ }
+ if (! gda_set_set_holder_value (params, &error, "id", "9")) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Could not get SELECT's parameters!\n");
+#endif
+ goto out;
+ }
+
+ ramodel = gda_connection_statement_execute_select (cnc, stmt, params, NULL);
+ g_assert (ramodel);
+ model = gda_connection_statement_execute_select_full (cnc, stmt, params,
+ GDA_STATEMENT_MODEL_CURSOR_FORWARD,
+ NULL, &error);
+ if (!model) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Could not execute SELECT!\n");
+#endif
+ goto out;
+ }
+ if (!GDA_IS_DATA_SELECT (model)) {
+ g_print ("Data model should be a GdaDataSelect!\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* create an iterator */
+ ncols = gda_data_model_get_n_columns (model);
+ nrows = gda_data_model_get_n_rows (ramodel);
+ iter = gda_data_model_create_iter (model);
+ for (; gda_data_model_iter_move_next (iter);) {
+ //g_print ("Iter is now at row %d\n", gda_data_model_iter_get_row (iter));
+ gint i;
+ for (i = 0; i < ncols; i++) {
+ const GValue *cvalue, *refcvalue;
+ cvalue = gda_data_model_iter_get_value_at (iter, i);
+ if (!cvalue) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Could not read GdaDataModelIter's value at col=%d\n", i);
+#endif
+ goto out;
+ }
+ refcvalue = gda_data_model_get_value_at (ramodel, i, gda_data_model_iter_get_row (iter), NULL);
+ g_assert (refcvalue);
+ if (gda_value_differ (cvalue, refcvalue)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("GdaDataModelIter and GdaDataModel values differ at col %d and row %d\n", i,
+ gda_data_model_iter_get_row (iter));
+#endif
+ goto out;
+ }
+ //g_print ("\t col %d => value %s\n", i, gda_value_stringify (cvalue));
+ }
+ }
+ if (gda_data_model_iter_is_valid (iter)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("GdaDataModelIter is valid => an error occurred!\n");
+#endif
+ goto out;
+ }
+ if (nrows != gda_data_model_get_n_rows (model)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_get_n_rows () returned %d when %d was expected\n",
+ gda_data_model_get_n_rows (model), nrows);
+#endif
+ goto out;
+ }
+ g_object_unref (iter);
+
+ /* create an iterator */
+ iter = gda_data_model_create_iter (model);
+ if (gda_data_model_iter_move_next (iter)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_iter_move_next() should have failed because CURSOR_FORWARD was only requested (for SQLite)\n");
+#endif
+ goto out;
+ }
+ g_object_unref (iter);
+
+ out:
+ g_object_unref (ramodel);
+ g_object_unref (model);
+ g_object_unref (stmt);
+ g_object_unref (params);
+
+ return nfailed;
+}
+
+/*
+ * Modifications using an iterator
+ *
+ * Returns the number of failures
+ */
+static gint
+test12 (GdaConnection *cnc)
+{
+ GError *error = NULL;
+ GdaDataModel *model;
+ GdaStatement *stmt;
+ gint nfailed = 0;
+ GdaSet *params;
+ GdaDataModelIter *iter;
+ GValue *value;
+ const GValue *cvalue;
+
+ clear_signals ();
+
+ /* create GdaDataSelect */
+ stmt = stmt_from_string ("SELECT * FROM customers WHERE id <= ##id::int");
+ g_assert (gda_statement_get_parameters (stmt, ¶ms, NULL));
+ g_assert (gda_set_set_holder_value (params, &error, "id", "9"));
+ model = gda_connection_statement_execute_select_full (cnc, stmt, params,
+ GDA_STATEMENT_MODEL_CURSOR_FORWARD,
+ NULL, &error);
+ g_assert (model);
+ monitor_model_signals (model);
+
+ /* gda_data_select_compute_modification_statements() */
+ if (!gda_data_select_compute_modification_statements (GDA_DATA_SELECT (model), &error)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_select_compute_modification_statements() should have succedded, error: %s\n",
+ error && error->message ? error->message : "No detail");
+#endif
+ goto out;
+ }
+
+ /* create an iterator */
+ iter = gda_data_model_create_iter (model);
+ if (! gda_data_model_iter_move_next (iter)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_iter_move_next() failed => can't go to 1st row\n");
+#endif
+ goto out;
+ }
+
+ if (! gda_data_model_iter_move_next (iter)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_iter_move_next() failed => can't go to 2nd row\n");
+#endif
+ goto out;
+ }
+
+ g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "Nick");
+ if (! gda_set_set_holder_value (GDA_SET (iter), &error, "name", "Nick")) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("GdaDataModelIter value set failed: %s\n",
+ error && error->message ? error->message : "No detail");
+#endif
+ goto out;
+ }
+ if (! check_expected_signal (model, 'U', 1)) {
+ nfailed++;
+ goto out;
+ }
+ cvalue = gda_data_model_iter_get_value_at (iter, 1);
+ if (!cvalue) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_iter_get_value_at() failed after modification\n");
+#endif
+ goto out;
+ }
+ if (gda_value_differ (cvalue, value)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_iter_get_value_at() and modified value differ\n");
+#endif
+ goto out;
+ }
+ g_object_unref (iter);
+
+
+ out:
+ g_object_unref (model);
+ g_object_unref (stmt);
+ g_object_unref (params);
+
+ return nfailed;
+}
+
+/*
+ * check gda_data_model_set_value_at(), fields order in the SELECT does not follow table's fields order
+ *
+ * Returns the number of failures
+ */
+static gint
+test13 (GdaConnection *cnc)
+{
+ GError *error = NULL;
+ GdaDataModel *model;
+ GdaStatement *stmt, *mod_stmt;
+ gint nfailed = 0;
+ GValue *value;
+
+ clear_signals ();
+
+ /* create GdaDataSelect */
+ stmt = stmt_from_string ("SELECT name, last_update, id FROM customers");
+ model = gda_connection_statement_execute_select (cnc, stmt, NULL, &error);
+ if (!model) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Could not execute SELECT!\n");
+#endif
+ goto out;
+ }
+ if (!GDA_IS_DATA_SELECT (model)) {
+ g_print ("Data model should be a GdaDataSelect!\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* test INSERT with undefined params */
+ mod_stmt = stmt_from_string ("UPDATE customers SET name = ##+0::string, last_update = ##+1::timestamp WHERE id = ##-2::gint");
+ if (!gda_data_select_set_modification_statement (GDA_DATA_SELECT (model), mod_stmt, &error)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_select_set_modification_statement() should have succedded, error: %s\n",
+ error && error->message ? error->message : "No detail");
+#endif
+ goto out;
+ }
+
+ /****/
+ monitor_model_signals (model);
+ g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "Jack");
+ if (! check_set_value_at (model, 0, 0, value, cnc, stmt, NULL)) {
+ nfailed ++;
+ goto out;
+ }
+ if (! check_expected_signal (model, 'U', 0)) {
+ nfailed++;
+ goto out;
+ }
+ gda_value_free (value);
+ clear_signals ();
+
+ /****/
+ gda_value_set_from_string ((value = gda_value_new (GDA_TYPE_TIMESTAMP)),
+ "2009-11-30 11:22:33", GDA_TYPE_TIMESTAMP);
+ if (! check_set_value_at (model, 1, 1, value, cnc, stmt, NULL)) {
+ nfailed ++;
+ goto out;
+ }
+ gda_value_free (value);
+
+ /****/
+ g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "Henry");
+ if (! check_set_value_at (model, 0, 0, value, cnc, stmt, NULL)) {
+ nfailed ++;
+ goto out;
+ }
+ gda_value_free (value);
+
+ /****/
+ g_value_set_int ((value = gda_value_new (G_TYPE_INT)), 555);
+ if (gda_data_model_set_value_at (model, 2, 0, value, &error)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_set_value_at should have failed\n");
+#endif
+ goto out;
+ }
+ gda_value_free (value);
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Got expected error: %s\n", error && error->message ? error->message : "No detail");
+#endif
+ g_error_free (error);
+
+ out:
+ g_object_unref (model);
+ g_object_unref (stmt);
+
+ return nfailed;
+}
+
+/*
+ * check gda_data_model_set_value_at(), fields order in the SELECT does not follow table's fields order,
+ * auto computing UPDATE statement
+ *
+ * Returns the number of failures
+ */
+static gint
+test14 (GdaConnection *cnc)
+{
+ GError *error = NULL;
+ GdaDataModel *model;
+ GdaStatement *stmt;
+ gint nfailed = 0;
+ GValue *value;
+
+ clear_signals ();
+
+ /* create GdaDataSelect */
+ stmt = stmt_from_string ("SELECT name, last_update, id FROM customers");
+ model = gda_connection_statement_execute_select (cnc, stmt, NULL, &error);
+ if (!model) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("Could not execute SELECT!\n");
+#endif
+ goto out;
+ }
+ if (!GDA_IS_DATA_SELECT (model)) {
+ g_print ("Data model should be a GdaDataSelect!\n");
+ exit (EXIT_FAILURE);
+ }
+
+ /* test INSERT with undefined params */
+ if (!gda_data_select_compute_modification_statements (GDA_DATA_SELECT (model), &error)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_select_compute_modification_statements() should have succedded, error: %s\n",
+ error && error->message ? error->message : "No detail");
+#endif
+ goto out;
+ }
+
+ /****/
+ monitor_model_signals (model);
+ g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "EJack");
+ if (! check_set_value_at (model, 0, 0, value, cnc, stmt, NULL)) {
+ nfailed ++;
+ goto out;
+ }
+ if (! check_expected_signal (model, 'U', 0)) {
+ nfailed++;
+ goto out;
+ }
+ gda_value_free (value);
+ clear_signals ();
+
+ /****/
+ gda_value_set_from_string ((value = gda_value_new (GDA_TYPE_TIMESTAMP)),
+ "2019-11-30 11:22:33", GDA_TYPE_TIMESTAMP);
+ if (! check_set_value_at (model, 1, 1, value, cnc, stmt, NULL)) {
+ nfailed ++;
+ goto out;
+ }
+ gda_value_free (value);
+
+ /****/
+ g_value_set_string ((value = gda_value_new (G_TYPE_STRING)), "IHenry");
+ if (! check_set_value_at (model, 0, 0, value, cnc, stmt, NULL)) {
+ nfailed ++;
+ goto out;
+ }
+ gda_value_free (value);
+
+ /****/
+ g_value_set_int ((value = gda_value_new (G_TYPE_INT)), 555);
+ if (!gda_data_model_set_value_at (model, 2, 0, value, &error)) {
+ nfailed++;
+#ifdef CHECK_EXTRA_INFO
+ g_print ("gda_data_model_set_value_at should not have failed: %s\n",
+ error && error->message ? error->message : "No detail");
+#endif
+ goto out;
+ }
+ gda_value_free (value);
+
+ out:
+ g_object_unref (model);
+ g_object_unref (stmt);
+
+ return nfailed;
+}
/*
* Checking value function:
Modified: trunk/tests/data-models/pmodel_data_customers.xml
==============================================================================
--- trunk/tests/data-models/pmodel_data_customers.xml (original)
+++ trunk/tests/data-models/pmodel_data_customers.xml Tue Sep 9 20:42:53 2008
@@ -1,11 +1,11 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="id" title="id" gdatype="gint" size="-1" scale="-1" pkey="TRUE" unique="TRUE"/>
- <gda_array_field id="FI1" name="name" title="name" gdatype="gchararray" size="-1" scale="-1"/>
- <gda_array_field id="FI2" name="last_update" title="last_update" gdatype="GdaTimestamp" size="-1" scale="-1"/>
- <gda_array_field id="FI3" name="default_served_by" title="default_served_by" gdatype="gint" size="-1" scale="-1" nullok="TRUE"/>
- <gda_array_field id="FI4" name="country" title="country" gdatype="gchararray" size="-1" scale="-1" nullok="TRUE"/>
- <gda_array_field id="FI5" name="city" title="city" gdatype="gchararray" size="-1" scale="-1" nullok="TRUE"/>
+ <gda_array_field id="FI0" name="id" title="id" gdatype="gint"/>
+ <gda_array_field id="FI1" name="name" title="name" gdatype="gchararray"/>
+ <gda_array_field id="FI2" name="last_update" title="last_update" gdatype="GdaTimestamp"/>
+ <gda_array_field id="FI3" name="default_served_by" title="default_served_by" gdatype="gint" nullok="TRUE"/>
+ <gda_array_field id="FI4" name="country" title="country" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI5" name="city" title="city" gdatype="gchararray" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>2</gda_value>
Modified: trunk/tests/data-models/pmodel_data_locations.xml
==============================================================================
--- trunk/tests/data-models/pmodel_data_locations.xml (original)
+++ trunk/tests/data-models/pmodel_data_locations.xml Tue Sep 9 20:42:53 2008
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="country" title="country" gdatype="gchararray" size="-1" scale="-1" pkey="TRUE" unique="TRUE"/>
- <gda_array_field id="FI1" name="city" title="city" gdatype="gchararray" size="-1" scale="-1" pkey="TRUE" unique="TRUE"/>
- <gda_array_field id="FI2" name="shortcut" title="shortcut" gdatype="gchararray" size="-1" scale="-1"/>
+ <gda_array_field id="FI0" name="country" title="country" gdatype="gchararray"/>
+ <gda_array_field id="FI1" name="city" title="city" gdatype="gchararray"/>
+ <gda_array_field id="FI2" name="shortcut" title="shortcut" gdatype="gchararray"/>
<gda_array_data>
<gda_array_row>
<gda_value>FR</gda_value>
Modified: trunk/tests/meta-store/common.c
==============================================================================
--- trunk/tests/meta-store/common.c (original)
+++ trunk/tests/meta-store/common.c Tue Sep 9 20:42:53 2008
@@ -24,7 +24,7 @@
common_declare_meta_store (GdaMetaStore *store)
{
g_signal_connect (store, "meta-changed", G_CALLBACK (meta_changed_cb), NULL);
- g_signal_connect (store, "suggest_update", G_CALLBACK (suggest_update_cb), NULL);
+ g_signal_connect (store, "suggest-update", G_CALLBACK (suggest_update_cb), NULL);
}
static void
Modified: trunk/tests/parser/testvalid.xml
==============================================================================
--- trunk/tests/parser/testvalid.xml (original)
+++ trunk/tests/parser/testvalid.xml Tue Sep 9 20:42:53 2008
@@ -100,8 +100,8 @@
<sql valid="t">SELECT name, *, city FROM customers</sql>
<normalized>{"statement":{"sql":"SELECT name, *, city FROM customers","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"name"},"field_name":"name"},{"expr":{"value":"id"},"field_name":"id"},{"expr":{"value":"name"},"field_name":"name"},{"expr":{"value":"default_served_by"},"field_name":"default_served_by"},{"expr":{"value":"country"},"field_name":"country"},{"expr":{"value":"city"},"field_name":"city"},{"expr":{"value":"city"},"field_name":"city"}],"from":{"targets":[{"expr":{"value":"customers"},"table_name":"customers"}]}}}}</normalized>
<insert>{"statement":{"sql":null,"stmt_type":"INSERT","contents":{"table":"customers","fields":["name","id","default_served_by","country","city"],"values":[[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}]]}}}</insert>
- <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["name","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
- <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
+ <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["name","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
+ <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
</test>
<test id="N2">
@@ -118,24 +118,24 @@
<sql valid="t">SELECT "name", c.*, "id" FROM customers as c</sql>
<normalized>{"statement":{"sql":"SELECT \"name\", c.*, \"id\" FROM customers as c","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"\"name\""},"field_name":"\"name\""},{"expr":{"value":"c.id"},"field_name":"id","table_name":"c"},{"expr":{"value":"c.name"},"field_name":"name","table_name":"c"},{"expr":{"value":"c.default_served_by"},"field_name":"default_served_by","table_name":"c"},{"expr":{"value":"c.country"},"field_name":"country","table_name":"c"},{"expr":{"value":"c.city"},"field_name":"city","table_name":"c"},{"expr":{"value":"\"id\""},"field_name":"\"id\""}],"from":{"targets":[{"expr":{"value":"customers"},"table_name":"customers","as":"c"}]}}}}</normalized>
<insert>{"statement":{"sql":null,"stmt_type":"INSERT","contents":{"table":"customers","fields":["\"name\"","id","default_served_by","country","city"],"values":[[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}]]}}}</insert>
- <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["\"name\"","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
- <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
+ <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["\"name\"","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
+ <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
</test>
<test id="N4">
<sql valid="t">SELECT "name", "customers".*, "id" FROM customers as c</sql>
<normalized>{"statement":{"sql":"SELECT \"name\", \"customers\".*, \"id\" FROM customers as c","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"\"name\""},"field_name":"\"name\""},{"expr":{"value":"\"customers\".id"},"field_name":"id","table_name":"\"customers\""},{"expr":{"value":"\"customers\".name"},"field_name":"name","table_name":"\"customers\""},{"expr":{"value":"\"customers\".default_served_by"},"field_name":"default_served_by","table_name":"\"customers\""},{"expr":{"value":"\"customers\".country"},"field_name":"country","table_name":"\"customers\""},{"expr":{"value":"\"customers\".city"},"field_name":"city","table_name":"\"customers\""},{"expr":{"value":"\"id\""},"field_name":"\"id\""}],"from":{"targets":[{"expr":{"value":"customers"},"table_name":"customers","as":"c"}]}}}}</normalized>
<insert>{"statement":{"sql":null,"stmt_type":"INSERT","contents":{"table":"customers","fields":["\"name\"","id","default_served_by","country","city"],"values":[[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}]]}}}</insert>
- <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["\"name\"","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
- <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
+ <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["\"name\"","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
+ <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
</test>
<test id="N5">
<sql valid="t">SELECT NaMe, c."*", ID FROM customers as c</sql>
<normalized>{"statement":{"sql":"SELECT NaMe, c.\"*\", ID FROM customers as c","stmt_type":"SELECT","contents":{"distinct":"false","fields":[{"expr":{"value":"NaMe"},"field_name":"NaMe"},{"expr":{"value":"c.id"},"field_name":"id","table_name":"c"},{"expr":{"value":"c.name"},"field_name":"name","table_name":"c"},{"expr":{"value":"c.default_served_by"},"field_name":"default_served_by","table_name":"c"},{"expr":{"value":"c.country"},"field_name":"country","table_name":"c"},{"expr":{"value":"c.city"},"field_name":"city","table_name":"c"},{"expr":{"value":"ID"},"field_name":"ID"}],"from":{"targets":[{"expr":{"value":"customers"},"table_name":"customers","as":"c"}]}}}}</normalized>
<insert>{"statement":{"sql":null,"stmt_type":"INSERT","contents":{"table":"customers","fields":["NaMe","id","default_served_by","country","city"],"values":[[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}]]}}}</insert>
- <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["NaMe","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
- <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-0","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
+ <update>{"statement":{"sql":null,"stmt_type":"UPDATE","contents":{"table":"customers","fields":["NaMe","id","default_served_by","country","city"],"expressions":[{"value":null,"param_spec":{"name":"+0","descr":null,"type":"gchararray","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+1","descr":null,"type":"gint","is_param":false,"nullok":false}},{"value":null,"param_spec":{"name":"+3","descr":null,"type":"gint","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+4","descr":null,"type":"gchararray","is_param":false,"nullok":true}},{"value":null,"param_spec":{"name":"+5","descr":null,"type":"gchararray","is_param":false,"nullok":true}}],"condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</update>
+ <delete>{"statement":{"sql":null,"stmt_type":"DELETE","contents":{"table":"customers","condition":{"operation":{"operator":"=","operand0":{"value":"id"},"operand1":{"value":null,"param_spec":{"name":"-1","descr":null,"type":"gint","is_param":false,"nullok":false}}}}}}}</delete>
</test>
</testdata>
Modified: trunk/tests/providers/DATA_actor.xml
==============================================================================
--- trunk/tests/providers/DATA_actor.xml (original)
+++ trunk/tests/providers/DATA_actor.xml Tue Sep 9 20:42:53 2008
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="actor_id" title="actor_id" gdatype="gint" size="4" nullok="TRUE" table="actor"/>
- <gda_array_field id="FI1" name="first_name" title="first_name" gdatype="gchararray" size="-1" nullok="TRUE" table="actor"/>
- <gda_array_field id="FI2" name="last_name" title="last_name" gdatype="gchararray" size="-1" nullok="TRUE" table="actor"/>
- <gda_array_field id="FI3" name="last_update" title="last_update" gdatype="GdaTimestamp" size="8" nullok="TRUE" table="actor"/>
+ <gda_array_field id="FI0" name="actor_id" title="actor_id" gdatype="gint" nullok="TRUE"/>
+ <gda_array_field id="FI1" name="first_name" title="first_name" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI2" name="last_name" title="last_name" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI3" name="last_update" title="last_update" gdatype="GdaTimestamp" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>1</gda_value>
Modified: trunk/tests/providers/DATA_film.xml
==============================================================================
--- trunk/tests/providers/DATA_film.xml (original)
+++ trunk/tests/providers/DATA_film.xml Tue Sep 9 20:42:53 2008
@@ -1,18 +1,18 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="film_id" title="film_id" gdatype="gint" size="4" nullok="TRUE" table="film"/>
- <gda_array_field id="FI1" name="title" title="title" gdatype="gchararray" size="-1" nullok="TRUE" table="film"/>
- <gda_array_field id="FI2" name="description" title="description" gdatype="gchararray" size="-1" nullok="TRUE" table="film"/>
- <gda_array_field id="FI3" name="release_year" title="release_year" gdatype="gint" size="4" nullok="TRUE" table="film"/>
- <gda_array_field id="FI4" name="language_id" title="language_id" gdatype="GdaShort" size="2" nullok="TRUE" table="film"/>
- <gda_array_field id="FI5" name="original_language_id" title="original_language_id" gdatype="GdaShort" size="2" nullok="TRUE" table="film"/>
- <gda_array_field id="FI6" name="rental_duration" title="rental_duration" gdatype="GdaShort" size="2" nullok="TRUE" table="film"/>
- <gda_array_field id="FI7" name="rental_rate" title="rental_rate" gdatype="GdaNumeric" size="-1" nullok="TRUE" table="film"/>
- <gda_array_field id="FI8" name="length" title="length" gdatype="GdaShort" size="2" nullok="TRUE" table="film"/>
- <gda_array_field id="FI9" name="replacement_cost" title="replacement_cost" gdatype="GdaNumeric" size="-1" nullok="TRUE" table="film"/>
- <gda_array_field id="FI10" name="rating" title="rating" gdatype="gchararray" size="-1" nullok="TRUE" table="film"/>
- <gda_array_field id="FI11" name="last_update" title="last_update" gdatype="GdaTimestamp" size="8" nullok="TRUE" table="film"/>
- <gda_array_field id="FI12" name="special_features" title="special_features" gdatype="gchararray" size="-1" nullok="TRUE" table="film"/>
+ <gda_array_field id="FI0" name="film_id" title="film_id" gdatype="gint" nullok="TRUE"/>
+ <gda_array_field id="FI1" name="title" title="title" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI2" name="description" title="description" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI3" name="release_year" title="release_year" gdatype="gint" nullok="TRUE"/>
+ <gda_array_field id="FI4" name="language_id" title="language_id" gdatype="GdaShort" nullok="TRUE"/>
+ <gda_array_field id="FI5" name="original_language_id" title="original_language_id" gdatype="GdaShort" nullok="TRUE"/>
+ <gda_array_field id="FI6" name="rental_duration" title="rental_duration" gdatype="GdaShort" nullok="TRUE"/>
+ <gda_array_field id="FI7" name="rental_rate" title="rental_rate" gdatype="GdaNumeric" nullok="TRUE"/>
+ <gda_array_field id="FI8" name="length" title="length" gdatype="GdaShort" nullok="TRUE"/>
+ <gda_array_field id="FI9" name="replacement_cost" title="replacement_cost" gdatype="GdaNumeric" nullok="TRUE"/>
+ <gda_array_field id="FI10" name="rating" title="rating" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI11" name="last_update" title="last_update" gdatype="GdaTimestamp" nullok="TRUE"/>
+ <gda_array_field id="FI12" name="special_features" title="special_features" gdatype="gchararray" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>1</gda_value>
Modified: trunk/tests/providers/DATA_film_actor.xml
==============================================================================
--- trunk/tests/providers/DATA_film_actor.xml (original)
+++ trunk/tests/providers/DATA_film_actor.xml Tue Sep 9 20:42:53 2008
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="actor_id" title="actor_id" gdatype="GdaShort" size="2" nullok="TRUE" table="film_actor"/>
- <gda_array_field id="FI1" name="film_id" title="film_id" gdatype="GdaShort" size="2" nullok="TRUE" table="film_actor"/>
- <gda_array_field id="FI2" name="last_update" title="last_update" gdatype="GdaTimestamp" size="8" nullok="TRUE" table="film_actor"/>
+ <gda_array_field id="FI0" name="actor_id" title="actor_id" gdatype="GdaShort" nullok="TRUE"/>
+ <gda_array_field id="FI1" name="film_id" title="film_id" gdatype="GdaShort" nullok="TRUE"/>
+ <gda_array_field id="FI2" name="last_update" title="last_update" gdatype="GdaTimestamp" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>1</gda_value>
Modified: trunk/tests/providers/DATA_language.xml
==============================================================================
--- trunk/tests/providers/DATA_language.xml (original)
+++ trunk/tests/providers/DATA_language.xml Tue Sep 9 20:42:53 2008
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="language_id" title="language_id" gdatype="gint" size="4" nullok="TRUE" table="language"/>
- <gda_array_field id="FI1" name="name" title="name" gdatype="gchararray" size="-1" nullok="TRUE" table="language"/>
- <gda_array_field id="FI2" name="last_update" title="last_update" gdatype="GdaTimestamp" size="8" nullok="TRUE" table="language"/>
+ <gda_array_field id="FI0" name="language_id" title="language_id" gdatype="gint" nullok="TRUE"/>
+ <gda_array_field id="FI1" name="name" title="name" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI2" name="last_update" title="last_update" gdatype="GdaTimestamp" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>1</gda_value>
Modified: trunk/tests/providers/TYPES_SCHEMA_PostgreSQL.xml
==============================================================================
--- trunk/tests/providers/TYPES_SCHEMA_PostgreSQL.xml (original)
+++ trunk/tests/providers/TYPES_SCHEMA_PostgreSQL.xml Tue Sep 9 20:42:53 2008
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="short_type_name" title="short_type_name" gdatype="gchararray" size="-1" scale="-1"/>
- <gda_array_field id="FI1" name="gtype" title="gtype" gdatype="gchararray" size="-1" scale="-1"/>
- <gda_array_field id="FI2" name="comments" title="comments" gdatype="gchararray" size="-1" scale="-1" nullok="TRUE"/>
- <gda_array_field id="FI3" name="synonyms" title="synonyms" gdatype="null" size="-1" scale="-1" nullok="TRUE"/>
+ <gda_array_field id="FI0" name="short_type_name" title="short_type_name" gdatype="gchararray"/>
+ <gda_array_field id="FI1" name="gtype" title="gtype" gdatype="gchararray"/>
+ <gda_array_field id="FI2" name="comments" title="comments" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI3" name="synonyms" title="synonyms" gdatype="null" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>abstime</gda_value>
Modified: trunk/tests/providers/TYPES_SCHEMA_SQLite.xml
==============================================================================
--- trunk/tests/providers/TYPES_SCHEMA_SQLite.xml (original)
+++ trunk/tests/providers/TYPES_SCHEMA_SQLite.xml Tue Sep 9 20:42:53 2008
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<gda_array id="EXPORT" name="Exported Data">
- <gda_array_field id="FI0" name="short_type_name" title="short_type_name" gdatype="gchararray" size="-1" scale="-1"/>
- <gda_array_field id="FI1" name="gtype" title="gtype" gdatype="gchararray" size="-1" scale="-1"/>
- <gda_array_field id="FI2" name="comments" title="comments" gdatype="gchararray" size="-1" scale="-1" nullok="TRUE"/>
- <gda_array_field id="FI3" name="synonyms" title="synonyms" gdatype="gchararray" size="-1" scale="-1" nullok="TRUE"/>
+ <gda_array_field id="FI0" name="short_type_name" title="short_type_name" gdatype="gchararray"/>
+ <gda_array_field id="FI1" name="gtype" title="gtype" gdatype="gchararray"/>
+ <gda_array_field id="FI2" name="comments" title="comments" gdatype="gchararray" nullok="TRUE"/>
+ <gda_array_field id="FI3" name="synonyms" title="synonyms" gdatype="gchararray" nullok="TRUE"/>
<gda_array_data>
<gda_array_row>
<gda_value>blob</gda_value>
Modified: trunk/tests/value-holders/check_holder.c
==============================================================================
--- trunk/tests/value-holders/check_holder.c (original)
+++ trunk/tests/value-holders/check_holder.c Tue Sep 9 20:42:53 2008
@@ -30,6 +30,7 @@
static gboolean test7 (GError **error);
static gboolean test8 (GError **error);
static gboolean test9 (GError **error);
+static gboolean test10 (GError **error);
TestFunc tests[] = {
test1,
@@ -40,7 +41,8 @@
test6,
test7,
test8,
- test9
+ test9,
+ test10
};
int
@@ -737,9 +739,9 @@
if (!gda_holder_set_source_model (h, model, 1, error))
return FALSE;
- if (!emitted_signals_find (h, "source_changed", error))
+ if (!emitted_signals_find (h, "source-changed", error))
return FALSE;
- if (!emitted_signals_chech_empty (NULL, "source_changed", error))
+ if (!emitted_signals_chech_empty (NULL, "source-changed", error))
return FALSE;
if ((gda_holder_get_source_model (h, &col) != model) || (col != 1)) {
@@ -751,9 +753,9 @@
/***/
if (!gda_holder_set_source_model (h, model, 0, error))
return FALSE;
- if (!emitted_signals_find (h, "source_changed", error))
+ if (!emitted_signals_find (h, "source-changed", error))
return FALSE;
- if (!emitted_signals_chech_empty (NULL, "source_changed", error))
+ if (!emitted_signals_chech_empty (NULL, "source-changed", error))
return FALSE;
if ((gda_holder_get_source_model (h, &col) != model) || (col != 0)) {
g_set_error (error, 0, 0,
@@ -764,9 +766,9 @@
/***/
if (!gda_holder_set_source_model (h, NULL, 0, error))
return FALSE;
- if (!emitted_signals_find (h, "source_changed", error))
+ if (!emitted_signals_find (h, "source-changed", error))
return FALSE;
- if (!emitted_signals_chech_empty (NULL, "source_changed", error))
+ if (!emitted_signals_chech_empty (NULL, "source-changed", error))
return FALSE;
if (gda_holder_get_source_model (h, NULL)) {
@@ -781,6 +783,101 @@
return TRUE;
}
+/*
+ * "before_change" signal
+ */
+
+static GError *
+t10_before_change_cb (GdaHolder *h, const GValue *value, gchar *token)
+{
+ /* only accept GDA_VALUE_NULL or the "hi!" G_TYPE_STRING value */
+ g_assert (!strcmp (token, "AToken"));
+
+ if (gda_value_is_null (value) || !strcmp (g_value_get_string (value), "hi!")) {
+ g_print ("GdaHolder change accepted\n");
+ return NULL;
+ }
+ else {
+ GError *error = NULL;
+ g_print ("GdaHolder change refused\n");
+ g_set_error (&error, 0, 0,
+ "GdaHolder change refused!");
+ return error;
+ }
+}
+
+static gboolean
+test10 (GError **error)
+{
+ GdaHolder *h;
+ const GValue *cvalue;
+ GValue *value;
+
+ h = gda_holder_new (G_TYPE_STRING);
+ emitted_signals_monitor_holder (h);
+
+ /***/
+ value = gda_value_new_from_string ("my string", G_TYPE_STRING);
+ emitted_signals_reset ();
+ if (!gda_holder_set_value (h, value, error))
+ return FALSE;
+ if (!emitted_signals_find (h, "changed", error))
+ return FALSE;
+ if (!emitted_signals_chech_empty (NULL, "changed", error))
+ return FALSE;
+ gda_value_free (value);
+
+ /***/
+ g_signal_connect (G_OBJECT (h), "before-change",
+ G_CALLBACK (t10_before_change_cb), "AToken");
+
+ /***/
+ value = gda_value_new_from_string ("my other string", G_TYPE_STRING);
+ emitted_signals_reset ();
+ if (gda_holder_set_value (h, value, error)) {
+ g_set_error (error, 0, 0,
+ "GdaHolder's change should have failed");
+ return FALSE;
+ }
+ if (!emitted_signals_chech_empty (NULL, "changed", error))
+ return FALSE;
+ gda_value_free (value);
+
+ /***/
+ value = gda_value_new_from_string ("my string", G_TYPE_STRING);
+ cvalue = gda_holder_get_value (h);
+ if (!cvalue || gda_value_differ (value, cvalue)) {
+ g_set_error (error, 0, 0,
+ "GdaHolder's value is incorrect");
+ return FALSE;
+ }
+ gda_value_free (value);
+
+
+ /***/
+ value = gda_value_new_from_string ("hi!", G_TYPE_STRING);
+ emitted_signals_reset ();
+ if (!gda_holder_set_value (h, value, error))
+ return FALSE;
+ if (!emitted_signals_find (h, "changed", error))
+ return FALSE;
+ if (!emitted_signals_chech_empty (NULL, "changed", error))
+ return FALSE;
+
+ /***/
+ cvalue = gda_holder_get_value (h);
+ if (!cvalue || gda_value_differ (value, cvalue)) {
+ g_set_error (error, 0, 0,
+ "GdaHolder's value is incorrect");
+ return FALSE;
+ }
+ gda_value_free (value);
+
+ g_object_unref (h);
+
+ return TRUE;
+}
+
/*
* Signals testing
@@ -867,7 +964,7 @@
EmittedSignal *es;
es = g_new0 (EmittedSignal, 1);
es->obj = obj;
- es->signal_name = "source_changed";
+ es->signal_name = "source-changed";
emitted_signal_add (es);
}
@@ -876,6 +973,6 @@
{
g_signal_connect (G_OBJECT (h), "changed",
G_CALLBACK (changed_cb), NULL);
- g_signal_connect (G_OBJECT (h), "source_changed",
+ g_signal_connect (G_OBJECT (h), "source-changed",
G_CALLBACK (source_changed_cb), NULL);
}
Modified: trunk/tests/value-holders/check_set.c
==============================================================================
--- trunk/tests/value-holders/check_set.c (original)
+++ trunk/tests/value-holders/check_set.c Tue Sep 9 20:42:53 2008
@@ -24,11 +24,13 @@
typedef gboolean (*TestFunc) (GError **);
static gboolean test1 (GError **error);
static gboolean test2 (GError **error);
+static gboolean test3 (GError **error);
GHashTable *data;
TestFunc tests[] = {
test1,
- test2
+ test2,
+ test3
};
int
@@ -118,9 +120,9 @@
return FALSE;
if (!tests_common_check_set (data, "T2.1", set, error)) return FALSE;
- if (!emitted_signals_find (set, "public_data_changed", error))
+ if (!emitted_signals_find (set, "public-data-changed", error))
return FALSE;
- if (!emitted_signals_chech_empty (set, "public_data_changed", error))
+ if (!emitted_signals_chech_empty (set, "public-data-changed", error))
return FALSE;
if (!tests_common_check_set (data, "T2.1", set, error)) return FALSE;
@@ -131,9 +133,9 @@
return FALSE;
if (!tests_common_check_set (data, "T2.2", set, error)) return FALSE;
- if (!emitted_signals_find (set, "public_data_changed", error))
+ if (!emitted_signals_find (set, "public-data-changed", error))
return FALSE;
- if (!emitted_signals_chech_empty (set, "public_data_changed", error))
+ if (!emitted_signals_chech_empty (set, "public-data-changed", error))
return FALSE;
/***/
@@ -142,15 +144,96 @@
return FALSE;
if (!tests_common_check_set (data, "T2.3", set, error)) return FALSE;
- if (!emitted_signals_find (set, "public_data_changed", error))
+ if (!emitted_signals_find (set, "public-data-changed", error))
return FALSE;
- if (!emitted_signals_chech_empty (set, "public_data_changed", error))
+ if (!emitted_signals_chech_empty (set, "public-data-changed", error))
return FALSE;
return TRUE;
}
/*
+ * "before_holder_change" signal
+ */
+static GError *
+t3_before_holder_change (GdaSet *set, GdaHolder *h, const GValue *value, gchar *token)
+{
+ /* only accept GDA_VALUE_NULL or 444 value */
+ g_assert (!strcmp (token, "MyToken"));
+
+ if (!strcmp (gda_holder_get_id (h), "H2")) {
+ if (gda_value_is_null (value) || (g_value_get_int (value) == 444)) {
+ g_print ("GdaHolder change accepted\n");
+ return NULL;
+ }
+ else {
+ GError *error = NULL;
+ g_print ("GdaHolder change refused\n");
+ g_set_error (&error, 0, 0,
+ "GdaHolder change refused!");
+ return error;
+ }
+ }
+ else
+ /* change accepted */
+ return NULL;
+}
+
+static gboolean
+test3 (GError **error)
+{
+ GdaSet *set;
+ GdaHolder *h;
+ GValue *value;
+ const GValue *cvalue;
+
+ set = gda_set_new_inline (3,
+ "H1", G_TYPE_STRING, "A string",
+ "H2", G_TYPE_INT, 1234,
+ "H3", G_TYPE_CHAR, 'r');
+
+ g_signal_connect (G_OBJECT (set), "before-holder-change",
+ G_CALLBACK (t3_before_holder_change), "MyToken");
+
+ h = gda_set_get_holder (set, "H2");
+ g_value_set_int ((value = gda_value_new (G_TYPE_INT)), 333);
+ if (gda_holder_set_value (h, value, NULL)) {
+ g_set_error (error, 0, 0,
+ "gda_holder_set_value() should have been refused and failed");
+ return FALSE;
+ }
+ gda_value_free (value);
+
+ /***/
+ g_value_set_int ((value = gda_value_new (G_TYPE_INT)), 1234);
+ cvalue = gda_set_get_holder_value (set, "H2");
+ if (!cvalue || gda_value_differ (value, cvalue)) {
+ g_set_error (error, 0, 0,
+ "GdaHolder's value is incorrect");
+ return FALSE;
+ }
+ gda_value_free (value);
+
+ /***/
+ g_value_set_int ((value = gda_value_new (G_TYPE_INT)), 444);
+ if (!gda_holder_set_value (h, value, error))
+ return FALSE;
+
+ /***/cvalue = gda_set_get_holder_value (set, "H2");
+ if (!cvalue || gda_value_differ (value, cvalue)) {
+ g_set_error (error, 0, 0,
+ "GdaHolder's value is incorrect");
+ return FALSE;
+ }
+ gda_value_free (value);
+
+
+ g_object_unref (set);
+
+ return TRUE;
+}
+
+/*
* Signals testing
*/
static void
@@ -244,12 +327,12 @@
static void
emitted_signals_monitor_set (GdaSet *set)
{
- g_signal_connect (G_OBJECT (set), "holder_changed",
- G_CALLBACK (set_1_cb), "holder_changed");
- g_signal_connect (G_OBJECT (set), "holder_plugin_changed",
- G_CALLBACK (set_1_cb), "holder_plugin_changed");
- g_signal_connect (G_OBJECT (set), "holder_attr_changed",
- G_CALLBACK (set_1_cb), "holder_attr_changed");
- g_signal_connect (G_OBJECT (set), "public_data_changed",
- G_CALLBACK (set_0_cb), "public_data_changed");
+ g_signal_connect (G_OBJECT (set), "holder-changed",
+ G_CALLBACK (set_1_cb), "holder-changed");
+ g_signal_connect (G_OBJECT (set), "holder-plugin-changed",
+ G_CALLBACK (set_1_cb), "holder-plugin-changed");
+ g_signal_connect (G_OBJECT (set), "holder-attr-changed",
+ G_CALLBACK (set_1_cb), "holder-attr-changed");
+ g_signal_connect (G_OBJECT (set), "public-data-changed",
+ G_CALLBACK (set_0_cb), "public-data-changed");
}
Modified: trunk/tools/gda-list-server-op.c
==============================================================================
--- trunk/tools/gda-list-server-op.c (original)
+++ trunk/tools/gda-list-server-op.c Tue Sep 9 20:42:53 2008
@@ -103,7 +103,7 @@
xmlNodePtr child;
for (child = node->last; child; ) {
xmlChar *lang = xmlGetProp (child, (xmlChar*)"lang");
- if (lang || !strcmp (child->name, "sources")) {
+ if (lang || !strcmp ((gchar *) child->name, "sources")) {
/* remove this node */
xmlNodePtr prev = child->prev;
if (lang)
@@ -152,15 +152,15 @@
path->path = pstr;
retlist = g_slist_append (retlist, path);
- if (!strcmp (node->name, "parameters"))
+ if (!strcmp ((gchar*) node->name, "parameters"))
path->node_type = GDA_SERVER_OPERATION_NODE_PARAMLIST;
- else if (!strcmp (node->name, "parameter"))
+ else if (!strcmp ((gchar*) node->name, "parameter"))
path->node_type = GDA_SERVER_OPERATION_NODE_PARAM;
- else if (!strcmp (node->name, "sequence"))
+ else if (!strcmp ((gchar*) node->name, "sequence"))
path->node_type = GDA_SERVER_OPERATION_NODE_SEQUENCE;
- else if (!strcmp (node->name, "gda_array"))
+ else if (!strcmp ((gchar*) node->name, "gda_array"))
path->node_type = GDA_SERVER_OPERATION_NODE_DATA_MODEL;
- else if (!strcmp (node->name, "gda_array_field")) {
+ else if (!strcmp ((gchar*) node->name, "gda_array_field")) {
path->node_type = GDA_SERVER_OPERATION_NODE_DATA_MODEL_COLUMN;
g_free (path->path);
pstr = g_strdup_printf ("%s/@%s", parent_path, id);
@@ -172,17 +172,17 @@
xmlChar *prop;
prop = xmlGetProp (node, BAD_CAST "name");
if (prop) {
- path->name = g_strdup (prop);
+ path->name = g_strdup ((gchar*) prop);
xmlFree (prop);
}
prop = xmlGetProp (node, BAD_CAST "descr");
if (prop) {
- path->descr = g_strdup (prop);
+ path->descr = g_strdup ((gchar*) prop);
xmlFree (prop);
}
prop = xmlGetProp (node, BAD_CAST "gdatype");
if (prop) {
- path->type = g_strdup (prop);
+ path->type = g_strdup ((gchar*) prop);
xmlFree (prop);
}
@@ -237,11 +237,11 @@
/* find node for this path ID, and create it if not yet present */
xmlNodePtr node = NULL;
for (node = root->children; node; node = node->next) {
- if (!strcmp (node->name, "path")) {
+ if (!strcmp ((gchar*) node->name, "path")) {
xmlChar *pid;
- pid = xmlGetProp (node, "id");
+ pid = xmlGetProp (node, BAD_CAST "id");
if (pid) {
- if (!strcmp (pid, path->path)) {
+ if (!strcmp ((gchar*) pid, path->path)) {
xmlFree (pid);
break;
}
@@ -275,16 +275,19 @@
xmlChar *node_type;
node_type = xmlGetProp (node, BAD_CAST "node_type");
g_assert (node_type);
- if (strcmp (node_type, node_type_to_string (path->node_type)))
- xmlSetProp (pnode, BAD_CAST "node_type", node_type_to_string (path->node_type));
+ if (strcmp ((gchar*) node_type,
+ node_type_to_string (path->node_type)))
+ xmlSetProp (pnode, BAD_CAST "node_type",
+ BAD_CAST node_type_to_string (path->node_type));
xmlFree (node_type);
/* check gdatype is similar to "node->gdatype" */
node_type = xmlGetProp (node, BAD_CAST "gdatype");
- if ((node_type && path->type && strcmp (node_type, path->type)) ||
+ if ((node_type && path->type &&
+ strcmp ((gchar*) node_type, path->type)) ||
(!node_type && path->type) ||
(node_type && *node_type && !path->type))
- xmlSetProp (pnode, BAD_CAST "gdatype", path->type);
+ xmlSetProp (pnode, BAD_CAST "gdatype", BAD_CAST path->type);
if (node_type)
xmlFree (node_type);
}
@@ -341,7 +344,7 @@
remove_all_extra (xmlDocGetRootElement (pdoc));
if (!doc) {
- doc = xmlNewDoc ("1.0");
+ doc = xmlNewDoc (BAD_CAST "1.0");
root = xmlNewNode (NULL, BAD_CAST "server_op");
xmlDocSetRootElement (doc, root);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]