[Erp5-dev] Re: sql_catalog_related_keys

Jean-Paul Smets jp at nexedi.com
Thu Jun 2 13:17:06 CEST 2005


Le jeudi 2 Juin 2005 09:36, Sebastien Robin a écrit :
> Hi,
>
> I have found something strange in the implementation of
> sql_catalog_related_keys.
>
> There is for example this:
> resource_type | movement,catalog/portal_type/z_related_resource
>
> This is great, this will do a join on the table movement. This works
> well.
>
> Now, I want to do the same thing with another table, for example I want
> to do a join with the table stock with the z_related_resource zsql
> method. For example:
> stock_resource_title | stock,catalog/title/z_related_resource
>
> And you know what ? Then the join will still happen on the movement
> table ! Indeed, the ZSQLCatalog assumes that there is only one way to use
> z_related_resource. So it will always use the same tables for table_0 and
> table_1, whatever we can put on our second sql_catalog_related_keys.
>
> Is it safe to modify the implementation ?

Well found.

Currently, there is an asumption of single join made per "joining 
method" (ex. z_related_resource).

If you plan to modify the implementation, here is what should be done to 
improve it:

	make sure a single join happens for every combination of
		(table list, joining method)

With the idea that if we need both stock_resource_title and 
stock_resource_id:
	stock_resource_title | stock,catalog/title/z_related_resource
	stock_resource_id | stock,catalog/id/z_related_resource

then only one join is made

but if we need:
	resource_type | movement,catalog/portal_type/z_related_resource
	stock_resource_title | stock,catalog/title/z_related_resource

then two independent joins are made

JPS.





-- 
Jean-Paul Smets-Solanes, Nexedi CEO - Tel. +33(0)6 62 05 76 14
Nexedi: Consulting and Development of Libre / Open Source Software
http://www.nexedi.com
ERP5: Libre/ Open Source ERP Software for small and medium companies
http://www.erp5.org
Rentalinux: Desktop Linux Server
http://www.rentalinux.com



More information about the Erp5-dev mailing list