Bug #17341
closedFieldmapping doesnt work on the "right side" in where clause with table.field
0%
Description
When table.field is given in a where clause on the right side, the mapping doesnt work.
// do we have a field name in the value?
// this is a very simplistic check, beware
if (!is_numeric($sqlPartArray[$k]['value'][0]) && !isset($sqlPartArray[$k]['value'][1])) {
$fieldArray = explode('.', $sqlPartArray[$k]['value'][0]);
if(count($fieldArray)==1 && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
$sqlPartArray[$k]['value'][0] = $this->mapping[$t]['mapFieldNames'][$fieldArray[0]];
} elseif(count($fieldArray)==2 && isset($this->mapping[$fieldArray[0]]['mapFieldNames'][$fieldArray[1]])) {
$sqlPartArray[$k]['value'][0] = $this->mapping[$fieldArray[0]]['mapTableName'].'.'.$this->mapping[$fieldArray[0]]['mapFieldNames'][$fieldArray[1]];
}
}
(issue imported from #M5708)
Updated by Karsten Dambekalns over 17 years ago
Could you please provide an example (code) where this does not work? It works for me...
Updated by Sebastian Fischer over 17 years ago
The following code block has a problem with the old mapping block:
$res = $this->typo3_db->exec_SELECTquery(
'cpg_categories.uid, cpg_categories.name',
'cpg_categories, pages',
'pages.uid = cpg_categories.pid AND pages.deleted = 0 AND 1 = 1',
'',
'cpg_categories.pos'
);
In Line 4 the comparison with cpg_categories.pid didnt mapped the pid to page_id. I dont know if if was because of problem with $t not holding the correct table, but i always got as result:
SELECT cpg_categories.cid, cpg_categories.name FROM cpg_categories, pages WHERE pages.uid =
cpg_categories.pid <== the mistake
AND pages.deleted = 0 AND 1 = 1 ORDER BY cpg_categories.pos
with the little change, the correct result state is:
SELECT cpg_categories.cid, cpg_categories.name FROM cpg_categories, pages WHERE pages.uid = cpg_categories.page_id AND pages.deleted = 0 AND 1 = 1 ORDER BY cpg_categories.pos
Updated by Xavier Perseguers about 15 years ago
I must be blind but I don't see what is wrong. The query you wrote contains as JOIN condition pages.uid = cpg_categories.pid.
You say it generates this condition while you expect DBAL to create a query with pages.uid = cpg_categories.page_id. I really don't understand why it should be like this.
I guess you have defined this mapping but forgot to mention it which makes this bug report hard if not impossible to understand:
$TYPO3_CONF_VARS['EXTCONF']['dbal']['mapping'] = array(
'cpg_categories' => array(
'mapFieldNames' => array(
'pid' => 'page_id',
),
),
);
Updated by Xavier Perseguers about 15 years ago
Added a unit-test for this problem as revision 26757 but could not reproduce this bug anymore.