Re: [gnome-db] append row to data model.
- From: Vivien Malerba <vmalerba gmail com>
- To: bas driessen xobas com
- Cc: GNOME-DB List <gnome-db-list gnome org>
- Subject: Re: [gnome-db] append row to data model.
- Date: Thu, 26 Jan 2006 11:12:05 +0100
2006/1/26, Bas Driessen <bas driessen xobas com>:
> On Thu, 2006-01-26 at 10:49 +0100, Vivien Malerba wrote:
> 2006/1/26, Bas Driessen <bas driessen xobas com>:
> [...]
> >
> > I agree with the concept to address this issue, but I don't believe this
> > code above will work OK. If I append a row with values to the datamodel,
> it
> > returns the line number of the new row and it exits. At that point I also
> > want to append it to the database. In the code above, you try to add the
> row
> > to the database if appending to the datamodel fails, but that is the other
> > way around if I read it correctly. I will do a some testing.
>
> Calling the gda_data_model_row_append_values() will
> (because the
> GdaPostgresRecordset object does not implement the GdaDataModelRow's
> append_value() virtual function):
> * create a new GdaRow object initialized with the correct values
> * call the GdaDataModelRow's append_row() virtual function which is
> defined in gda-postgres-recordset.c:208, and will do the job.
> * return the row number of the new row.
>
> Tell me if it works
>
>
> If I change the gda_data_model_row_append_values as below,
> it works OK. I just tested it.
>
> static gint
> gda_data_model_row_append_values (GdaDataModel *model,
> const GList *values, GError **error)
> {
> GdaRow *row;
>
> g_return_val_if_fail (GDA_IS_DATA_MODEL_ROW (model), -1);
> g_return_val_if_fail (CLASS (model)->append_values != NULL, -1);
>
> row = CLASS (model)->append_values (GDA_DATA_MODEL_ROW (model),
> values, error);
> if (row)
> {
> CLASS (model)->append_row (GDA_DATA_MODEL_ROW (model), row,
> error);
> return gda_row_get_number (row);
> }
> else
> return -1;
> }
>
>
Right, but this results in the GdaRow being added twice to the data
Hash data model (once when calling "row = CLASS
(model)->append_values...", and once when calling "CLASS
(model)->append_row").
May I suggest that you:
1) modify the above function to
static gint
gda_data_model_row_append_values (GdaDataModel *model, const GList
*values, GError **error)
{
GdaRow *row;
g_return_val_if_fail (GDA_IS_DATA_MODEL_ROW (model), -1);
g_return_val_if_fail (CLASS (model)->append_values != NULL, -1);
row = CLASS (model)->append_values (GDA_DATA_MODEL_ROW
(model), values, error);
if (row)
return gda_row_get_number (row);
else
return -1;
}
2) and modify line 206 of gda-data-model-hash.c to:
if (! GDA_DATA_MODEL_ROW_CLASS (G_OBJECT_GET_CLASS
(model))->append_row (model, row, error)) {
The idea is to make the gda_data_model_hash_append_values() function call
GdaPostgresRecordset's defined append_row() instead of calling
directly the GdaDataModelHash's append_row() function (which anyway
gets called at the end of the GdaPostgresRecordset's defined
append_row() function).
Can you try that?
Thanks,
Vivien
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]