GNOME Bugzilla – Bug 647272
Handle GValues with GType==0 as None, for libgda
Last modified: 2011-08-13 10:14:43 UTC
Created attachment 185584 [details] [review] 0001-pyg_value_as_pyobject-Return-None-for-a-GValue-with-.patch This patch fixes the gi.repository.Gda API, fixing the problem mentioned here: http://mail.gnome.org/archives/gnome-db-list/2011-April/msg00002.html This is necessary because libgda uses a GValue with a 0 GType to mean a Null database value. It has a gda_value_is_null() function that detects it, for instance.
By the way, I have no real idea if this is appropriate, or if the patch is correct.
If I'm right, GType 0 is G_TYPE_INVALID. It should not map to None but raise an error. G_TYPE_NONE seems more appropriate in this case. Why isn't it used?
Created attachment 185849 [details] test_value_none.c Test to show that GValue can't contain a G_TYPE_NONE.
G_TYPE_NONE does seem more appropriate, but this test shows that it's not currently possible. I see these warnings on the command-line: (process:30915): GLib-GObject-WARNING **: can't peek value table for type `void' which is not currently referenced (process:30915): GLib-GObject-WARNING **: gvalue.c:191: cannot initialize GValue with type `void', this type has no GTypeValueTable implementation Note that one of those is an error in the code that actually prints the warning in g_value_init(). Maybe libgda needs its own custom GDA_TYPE_NULL type that doesn't map to any existing type.
(In reply to comment #4) > > Maybe libgda needs its own custom GDA_TYPE_NULL type that doesn't map to any > existing type. I think it would make sense to have GDA_TYPE_NULL to refer to a SQL NULL value.
Or simply fix GObject to allow you to put G_TYPE_NONE into a GValue.
Please refer to Bug #647633. It have patches to solve this issue.
Does this mean that everything will be fixed in libgda and there are no modifications needed for PyGObject? Can this bug be closed?
It will probably be fixed in libgda, yes, but it's not fixed yet.
This is now fixed in libgda/master: http://git.gnome.org/browse/libgda/commit/?id=3f7456ef94b1b0f539267d02f32d8563dc9bb541