Basic split query (GDA backend)
Phil Longstaff
plongstaff at rogers.com
Tue Nov 21 18:53:35 EST 2006
On Mon, 2006-20-11 at 10:18 -0500, Derek Atkins wrote:
> 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..
I don't think it means that. If splits could be loaded separately from
transactions, I don't think it would even need to be special-cased. So
far, I have only ever seen queries for gncInvoice and Split objects,
whereas Account, Commodity and Price objects are loaded at initial
startup. I don't know about Lot objects or other business module
objects yet. I allow any search-for to need a special case, but at this
point, I think gncInvoice can use a general case. There will still need
to be some sort of qof-param -> sql field name translation (I don't know
if different sql engines allow column names to include '?').
>
> > 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. ;)
I know it is. I don't have a plan yet.
>
> > 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
More information about the gnucash-devel
mailing list