Re: [gnome-db] libgda-4.0 changes



On Wed, 2008-04-09 at 09:03 +0200, Vivien Malerba wrote:
> On Tue, Apr 8, 2008 at 9:10 PM, Murray Cumming <murrayc murrayc com> wrote:
> > The libgda-4.0 API reference is now online, and it contains information
> >  about the changes between libgda-3.0 and libgda-4.0:
> >  http://library.gnome.org/devel/libgda-4.0/unstable/migration-2.html
> >
> >  I have some comments from my initial tests:
> >
> >  1.
> >  Creating and executing SQL statements was never easy but it is now even
> >  more awkward than before because you must create a GdaSqlParser and use
> >  it, and check for an error when doing that:
> >
> >  libgda-3.0:
> >
> >   GdaCommand* command = gda_command_new("SELECT * FROM album",
> >     GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
> >   GdaDataModel* model =
> >     gda_connection_execute_select_command(connection, command, NULL /*
> >  params */, &error);
> >
> >
> >  libgda-4.0:
> >
> >   GdaSqlParser* parser = gda_connection_create_parser(connection);
> >   error = NULL;
> >   GdaStatement* statement = gda_sql_parser_parse_string(parser,
> >     "SELECT * FROM album",
> >     NULL /* remain */, &error);
> >   g_object_unref(parser);
> >
> >   if(error)
> >   {
> >     printf("GError from gda_sql_parser_parse_string(): %s\n",
> >  error->message);
> >     g_clear_error(&error);
> >     return EXIT_FAILURE;
> >   }
> >
> >   GdaDataModel* model =
> >     gda_connection_statement_execute_select(connection, statement,
> >  NULL /* params */, &error);
> >
> 
> The reason you need to create an SQL parser is that the parser can
> keep track of some specific SQL dialects such as MySQL "delimiter"
> command which allows one to change the ";" to mark the end of a
> command with something else. If you've got a general parser then you
> will inevitably run into trouble when for instance parsing some SQL in
> a file and parsing your own SQL commands...
> 
> However, in the general case you can still use
> gda_execute_select_command() or gda_execute_non_select_command() and
> the code above is reduced to one line.

Oh, I didn't know about those functions. I see they are listed here:
http://library.gnome.org/devel/libgda-4.0/3.99/libgda-40-Convenient-functions.html
(That should really say "convenience" functions.)

They should really be gda_connection_* functions, I think.

> >  2.
> >  The list of removed objects and functions needs information for eacho
> >  one about what should be used now:
> >  http://library.gnome.org/devel/libgda-4.0/unstable/ch07s05.html#id2561757
> 
> Yes...
> 
> >
> >  3.
> >  The
> >  GdaParameterList to GdaSet
> >  and GdaParameter to GdaHolder
> >  rename seems arbitary.
> >
> >  I guess that GdaSet should really be GdaValueSet or GdaValueList. Is it
> >  used for anything other than executing statements?
> 
> It is difficult to find good object names. GdaValueSet was pretty high
> on my list, however one would expect a GdaValueSet to contain GdaValue
> objects which IMO is too close to the GValue and would have caused
> misunderstandings.
> 
> Also GdaSet/GdaHolder are used in data model iterators, and also in
> some places to pass and unlimited list of named values.
> 
> >
> >  GdaHolder is a particularly obscure name. If not GdaParameter then maybe
> >  GdaNamedValue?
> 
> Renaming GdaSet to GdaValueSet and GdaHolder to GdaNamedValue would
> not be difficult, I can do it if you think they are better names.

I do personally, but let's see what other people suggest first.

-- 
murrayc murrayc com
www.murrayc.com
www.openismus.com



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