Merging two GNCBook* objects

Linas Vepstas linas at
Wed Apr 14 11:01:13 EDT 2004

On Fri, Apr 09, 2004 at 02:12:54PM -0400, Derek Atkins was heard to remark:
> Neil Williams <linux at> writes:
> If the GUID matches it's the always same semantic object, regardless
> of whether other data fields are changed.

I having been toying with the idea of always adding a version
number as a mandatory part of all objects, so that if you have
two objects with the same guid, then you know which one is the more
recent one.

> If the GUID doesn't match then you need some algorithm to detect
> whether the objects are the same semantically.  This algorithm is
> going to be object-type specific.  How you detect
> semantically-equivalent transactions is different than how you detect
> semantically-equivalent customers.

My gut instinct would be to hand-write a similarity-distance
function for each object, but you seem to want to auto-gen it. 
And maybe that's a good idea ... maybe better than hand-writing.

In that case, I would suggest writing a loop over all of the 
objects parameters and computing distance based on that.  We'd 
need to add a qof_class_for_each_parameter() func, or some such, 
so that you could find out about all of the parameters on an object, 
and then loop over each of them to do a compare.

Please look at QofParam in qofclass.h

The list of publically-visible paramters should be enough to 
tell how similar/distant two objects are. One should not
compare 'hidden'/'private' fields.

There ... problem solved, right?  ;-) The GUI merely presents the list
of objects that are sufficiently similar to each other, asking the 
user what to do about it ... 


pub  1024D/01045933 2001-02-01 Linas Vepstas (Labas!) <linas at>
PGP Key fingerprint = 8305 2521 6000 0B5E 8984  3F54 64A9 9A82 0104 5933

More information about the gnucash-devel mailing list