Project

General

Profile

Actions

Bug #17341

closed

Fieldmapping doesnt work on the "right side" in where clause with table.field

Added by Sebastian Fischer almost 17 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2007-05-30
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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)

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #17232: Fieldmapping doenst work on the "right side" in where clause.ClosedKarsten Dambekalns2007-04-23

Actions
Actions #1

Updated by Karsten Dambekalns almost 17 years ago

Could you please provide an example (code) where this does not work? It works for me...

Actions #2

Updated by Sebastian Fischer almost 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

Actions #3

Updated by Xavier Perseguers over 14 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',
),
),
);

Actions #4

Updated by Xavier Perseguers over 14 years ago

Added a unit-test for this problem as revision 26757 but could not reproduce this bug anymore.

Actions

Also available in: Atom PDF