Re: [gnome-db] GdaParameterList ignored? Ownership of GdaParameter. g_object_unref.



On Wed, 2002-09-25 at 06:17, Allan Wind wrote:
> libgda: 0.8.193
> postgres: 7.2.1
> 
> I am trying to run a simple parameterized (is there even a word like that?)
> query and expected this to do the trick, however the GdaParameterList
> argument to gda_connection_execute_single_command seem to be ignored
> as model contains my full table after running this piece of code.  Did I miss
> something here?
> 
the parameters are not supported yet, so yes, they are ignored.

> // initialize db
> // [...]
> 
> int id = 1;
> 
> GdaCommand *c = gda_command_new("select id, name from accounts", GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
> GdaValue *v = gda_value_new_integer(id);
> 
> GdaParameter *p = gda_parameter_new("id", GDA_VALUE_TYPE_INTEGER);
> gda_parameter_set_value(p, v);
> 
that will (when implemented) be wrong. The idea is that you use:

cmd = gda_command_new ("select id, name from accounts where id = :id",
...);
p = gda_parameter_new ("id", GDA_VALUE_TYPE_INTEGER)

so that the provider will replace :id with the value.

Anyway, as I said, there's no implementation for this yet :-(


> 
> Trial and error suggests that GdaParameterList takes ownership of GdaParameter
> upon gda_parameter_list_add_parameter(), that should probably be documented in
> libgda-gda-parameter.html.
> 
yes, that's correct, the parameter list takes ownership of the
parameter. I wonder if we should document that or change its behaviour,
so that it just gets a copy.

> It would also be nice if a paragraph on g_object_unref could be added to the
> tutorial, most other objects have a free function while model is an exception
> and use g_object_unref().  Perhaps a note could be added in the
> libgda-gdadatamodel.html as well?
> 
no, what we should do is to add a _free function to each
class/structure, in most cases just being those a call to
g_object_unref. That's what we've got in the GNOME 1.4 version.

> Btw, the latest revision of the html docs are really nice!
> 
thanks go to Xabier and Jose, who did all the job of updating and
extending the existing documentation.

cheers




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]