Re: [gnome-db] introspection issue
- From: Murray Cumming <murrayc murrayc com>
- To: Vivien Malerba <vmalerba gmail com>
- Cc: gnome-db list <gnome-db-list gnome org>
- Subject: Re: [gnome-db] introspection issue
- Date: Mon, 11 Apr 2011 10:29:22 +0200
On Sun, 2011-04-10 at 13:06 +0200, Murray Cumming wrote:
> On Sun, 2011-04-10 at 11:52 +0200, Murray Cumming wrote:
> > On Sat, 2011-04-09 at 18:39 +0200, Vivien Malerba wrote:
> > > On 8 April 2011 22:12, Murray Cumming <murrayc murrayc com> wrote:
> > > > GObject+Introspection is working quite well for me now with libgda.
> > > > Thanks. I am glad that pygda is now obsolete, so it's one less module
> > > > for me to maintain.
> > > >
> > > > However, I'm getting an error when trying to get the values from the
> > > > DataModel with get_value_at(). For instance, this script
> > > > http://git.gnome.org/browse/pygda/tree/examples/gda/select.py?h=introspection
> > > > produces this error:
> > > >
> > > > Traceback (most recent call last):
> > > > File "./select.py", line 61, in <module>
> > > > main ()
> > > > File "./select.py", line 57, in main
> > > > print " value=", data_model.get_value_at(col_index,
> > > > row_index);
> > > > File "/opt/gnome230/lib/python2.7/site-packages/gi/types.py", line 44,
> > > > in function
> > > > return info.invoke(*args)
> > > > TypeError: unknown type (null)
> > > >
> > > >
> > > > Presumably it doesn't like GdaValues with GType=0 (when
> > > > gda_value_is_null(gvalue) is true).
> > >
> > > Yes, the a GValue with a 0 GType represents a SQL NULL value, whereas
> > > if the returned value is NULL (the C NULL) then it means there was an
> > > error retreiving the value, hence the difference between the 2.
The PyGObject developers don't seem happy with this:
https://bugzilla.gnome.org/show_bug.cgi?id=647272#c2
Maybe it's something we can change in libgda-5.0.
> > Can we just ignore that meaning of C NULL? We might need to check that
> > everything throws a GError instead, but the GdaConnection functions
> > already do:
> > http://developer.gnome.org/libgda/unstable/GdaConnection.html#gda-connection-execute-select-command
> >
> > Otherwise we would need to distinguish between a SQL Null value and a C
> > NULL value, which would be hard in Python unless we have a Gda.Null
> > class with a GDA_TYPE_NULL GType. I don't think it's worth it unless we
> > can't always use GError instead.
>
> We might also want some automatic Python conversion between Gda.Numeric
> and python types such as Int. Otherwise we see errors such as this:
> TypeError: unsupported operand type(s) for +=: 'Numeric' and 'int'.
>
> We can instead do
> number = datamodel.get_value_at(0,0)
> actual_number = float(number.number)
> but that probably converts the number based on the current locale,
> instead of the C locale used by the GdaNumeric::number string.
>
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]