Bug #19999
closedtable name are not mapped in the value part of a query and in inner join
0%
Description
when having a query like this:
SELECT table1.* FROM table1 INNER JOIN table2 ON table1.uid = table2.fk_table1 WHERE table1.price < table2.cost
INNER JOIN and all other join(i suppose) are not supported for the mapping
table2 is not mapped in the where
ill make a ptach for this in a few days
(issue imported from #M10411)
Files
Updated by Xavier Perseguers about 15 years ago
Please give some code to reproduce this issue.
Updated by Michael Miousse about 15 years ago
the part from the where as been resolved in an other bug.
But the par for the join is still valid.
since that i pushed my investigation a bite further . joins are not mapped at all
i will have to remake my patch to suppresse the part of the where and to add and modify the mapping part for the join to fit with multiple joins
for the code to reproduce try this query and map all tables in the query and you will see that none of them are mapped:
$res= $GLOBALS['TYPO3_DB']->exec_SELECTquery('*','tt_news_cat inner join tt_news_cat_mm on tt_news_cat.uid = tt_news_cat_mm.uid_foreign inner join tt_news on tt_news.uid = tt_news_cat_mm.uid_local','1=1');
ps. sorry for the 2 bugs in one, i should have created 2 seperated bugs for this on
Updated by Michael Miousse about 15 years ago
Hi xavier
i have recreated my patch to only patch the mapping error of joins and i modified the parser in order to parse multiple joins in a query and inner joins.
could you read it and test it.
thx
Updated by Xavier Perseguers about 15 years ago
Hi Michael,
I started reviewing the changes. Thanks for the new patch. I'm currently working on it but a few comments:
- You copied 2 methods from TYPO3's core (in t3lib_sqlparser): methods parseFromTables and compileFromTables. There's a problem as I don't want to start fixing bugs in Core by copying faulty methods into DBAL, they have to be fixed there (I know that it's trickier to get code committed there). In addition by looking into what changed in method parseFromTables, you miss a patch I sent recently to allow aliasing on joined tables (#12071).
- [minor] CGL is not always respected (seems that it's related to code you copied though)
I'll prepare two patches, one for DBAL, the other for Core and will start again reviewing stuff with them.
Updated by Xavier Perseguers about 15 years ago
Example of renaming configuration for query given by Michael Miousse with message from 13.10.2009 14:10:
SQL:
------------------------------------------
RENAME TABLE 'tt_news' TO 'XP_tt_news';
ALTER TABLE `XP_tt_news` CHANGE `uid` `XP_uid` INT NOT NULL AUTO_INCREMENT
RENAME TABLE 'tt_news_cat' TO 'XP_tt_news_cat';
ALTER TABLE `XP_tt_news_cat` CHANGE `uid` `XP_uid` INT NOT NULL AUTO_INCREMENT
RENAME TABLE 'tt_news_cat_mm' TO 'XP_tt_news_cat_mm';
ALTER TABLE `XP_tt_news_cat_mm` CHANGE `uid_local` `XP_uid_local` INT UNSIGNED NOT NULL DEFAULT '0',
CHANGE `uid_foreign` `XP_uid_foreign` INT UNSIGNED NOT NULL DEFAULT '0'
localconf.php:
------------------------------------------
$TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] = array(
'tt_news' => array(
'mapTableName' => 'XP_tt_news',
'mapFieldNames' => array(
'uid' => 'XP_uid',
),
),
'tt_news_cat' => array(
'mapTableName' => 'XP_tt_news_cat',
'mapFieldNames' => array(
'uid' => 'XP_uid',
),
),
'tt_news_cat_mm' => array(
'mapTableName' => 'XP_tt_news_cat_mm',
'mapFieldNames' => array(
'uid_local' => 'XP_uid_local',
'uid_foreign' => 'XP_uid_foreign',
),
),
);
Updated by Michael Miousse about 15 years ago
Thx Xavier,
i will try to remember your comment for next patches
I'm happy of the dbal advancement
Updated by Xavier Perseguers about 15 years ago
Patches are deprecated in favor of bug #12440.