Basic split query (GDA backend)
Phil Longstaff
plongstaff at rogers.com
Fri Nov 17 21:39:45 EST 2006
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'
For each transaction and split, I load the associated slots.
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.
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.
Phil
More information about the gnucash-devel
mailing list