Basic split query (GDA backend)

Derek Atkins warlord at MIT.EDU
Mon Nov 20 10:18:24 EST 2006


Phil Longstaff <plongstaff at rogers.com> writes:

> I have the basic split query working.  I receive the query:
>
> (1) SELECT * FROM splits WHERE account_guid = 'XXX'
>
> and convert it to:
>
> (2) SELECT * FROM transactions WHERE guid IN
> 		(SELECT DISTINCT tx_guid FROM splits WHERE account_guid = 'XXX')
>
> Then, for each transaction, I load its splits as
>
> (3) SELECT * from SPLITS where tx_guid = 'YYY'

How do you know to automatically switch this Query?  What would it
do when searching for other objects?  Does this mean you need to
special-case every SearchFor()?  That seems.... Poor..

> For each transaction and split, I load the associated slots.

Well, that should happen for all objects, but good :)

> Yes, I realize that the transaction/split parent/child relation is such
> that I could create all of the transactions using (2) and then all of
> the splits using (1) and the correct splits would be assigned to the
> correct transactions.
>
> I do check if a transaction or split already exist.  If so, that object
> is reloaded.  Otherwise, a new one is malloc'ed.  In the multi-user case
> where a split may have been deleted from the transaction, I don't handle
> removing the corresponding Split object.  That might involve clearing a
> flag for each split, loading/reloading splits and marking each
> loaded/reloaded split, then looping for each split and deleting those
> whose flag is still clear.  Same issue for transactions.  In the
> single-user case, it can never happen.

Hmm..  Do you have a plan for how to detect objects deleted by another
client?  That's an important feature. ;)

> One issue I notice is that the query is run every time you click in the
> register.   If you build libgda with --enable-debug, it will print out
> each query as it is executed.  In the register, there are LOTS of these
> queries, all returning the same info.  I suppose in a multi-user system,
> you want absolute up-to-date info, but it seems a bit of overkill.

Yeah, it's run every time the window refreshes/reloads.  I don't know
if Chris' register-rewrite is better about that or not.

> Phil

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list