[TYPO3-core] RFC #10411: sqlparser is not able to parse more than 1 join

Xavier Perseguers typo3 at perseguers.ch
Wed Oct 28 18:12:28 CET 2009


Hi Oli,

> Xavier Perseguers schrieb:
>> Could you make a review of this patch? Having unit tests ease the test
>> that "it still works" and basically all you have to do is to apply patch
>> and see that TYPO3 is still running.
> 
> Are there any parts that would be particularly prone to break by this
> patch and that should be tested explicitly?

No because the parser works in two phases. First is to actually parse the query, done in our case by method parseFromTables() which is patched by first chunk. The parse* methods take a SQL string (or 
part of it) and parse the parts into an array that is returned. The decomposition basically allows DBAL (yes, this code is in Core but only used/invoked by DBAL) to remap field and table names (and in 
addition, according to the tables used, to dispatch the actual query to the correct database because many different databases may be involved even if only one per query is actually supported).

First chunk of the patch changes the way JOIN-parsed array is represented by adding a counter indicating for "which join" the sub-array gives the definition.

Second part of the parser is to take all those parts again into a query that may be executed by the database (as said, in between DBAL could "hook" and remap table and field names, add proper quoting, 
...). Second chunk of the patch is the pendent of parseFromTables() and is method compileFromTables(). All those compile* methods take an array as parameter and give a SQL query (or part of it) as 
return value.

This method is also patched to loop over all JOIN definitions to concatenate them.

As both methods were patched (parse* and compile*) to change the array structure, the output is strictly the same but now allows many JOINs to be used and successfully parsed. The rest (taking this 
additional "many-JOIN" structure into account for the remapping process is a pure DBAL-job and has nothing to do with Core.

Sadly, those methods are in Core but are only used by DBAL. The initial idea was to allow other extensions to use this but DBAL was - for sure - the only to take advantage of this and as such, when 
parsing in DBAL should be enhanced (because otherwise, without DBAL, query is sent directly without being parsed to MySQL), I have to send patch to the Core as I don't want to simply copy 
corresponding methods into class.ux_t3lib_sqlparser.php and leave code in Core deprecates itself...

I hope my explanation was clear.

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en

One contribution a day keeps the fork away


More information about the TYPO3-team-core mailing list