Project

General

Profile

Actions

Bug #17918

closed

Mapping of fieldnames in SQL-functions like MIN(), MAX() or SUM() does not work

Added by Christian Trabold over 16 years ago. Updated over 14 years ago.

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

0%

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

Description

If you use SQL-Functions like MIN, MAX or SUM in SQL-Queries the fieldmapping does not work. Example:

SELECT tstamp, script, SUM as calc_sum, count(*) AS qrycount, MAX as error FROM tx_dbal_debuglog

will produce

SELECT tstamp, script, SUM as calc_sum, count(*) AS qrycount, MAX as error FROM tx_dbal_debuglog

even if the mapping for the field "errorFlag" would be "errorflag" (with a small f).

This gets problematic if your database supports only lowercase fieldnames and the fieldname has upper-case letters (eg. tx_dbal_debuglog:errorFlag), because the field can not be found, which results in an error message.

With the attached patch the DBAL knows how to handle fieldnames inside SQL-Functions and maps it correctly to the desired value.

The patch adds a new condition in class.ux_t3lib_db.php->map_sqlParts() which checks for content in "func_content". If a mapping instruction for "func_content" can be found, the mapping will be processed.

Tested on Postgres 8.1.10 with DBAL 0.9.20 on TYPO3 4.1.2
(issue imported from #M6953)


Files

class.ux_t3lib_db.php.patch (840 Bytes) class.ux_t3lib_db.php.patch Administrator Admin, 2007-12-14 14:59
bug_6953_trunkrevision_4432.patch (1.34 KB) bug_6953_trunkrevision_4432.patch Administrator Admin, 2009-02-12 14:52
bug_6953_trunkrevision_24646.patch (1.62 KB) bug_6953_trunkrevision_24646.patch Administrator Admin, 2009-09-25 14:22
bug_6953_v4.diff (1.77 KB) bug_6953_v4.diff Administrator Admin, 2009-10-05 19:08
Actions #1

Updated by Michael Miousse about 15 years ago

this patch works fine for simple queries like select MAX from table where 1=1

but does not work for queries like select MAX from table,table2 where table.fk = table2.uid

i'll make an other patch from yours

Actions #2

Updated by Xavier Perseguers over 14 years ago

Hi,

Could you provide a patch against current trunk please ?

Actions #3

Updated by Michael Miousse over 14 years ago

Xavier the patch was made from the trunk but with revision 24646

could you take a look at it and see if everything is fine

Actions #4

Updated by Xavier Perseguers over 14 years ago

Michael,

Could you please test patch bug_6953_v4.diff which I rewrote in order to take CGL into account and to have same coding style as for bug #11119.

The patch was tested on Oracle and a mix of MSSQL and MySQL and had no side-effect. I would like to get a final test on your side to make sure it still behaves as it should. I will then commit it if it's OK.

Actions #5

Updated by Michael Miousse over 14 years ago

Tested and it worked as expected

thanks Xavier

Actions #6

Updated by Xavier Perseguers over 14 years ago

Committed revision 25171.

Actions

Also available in: Atom PDF