Project

General

Profile

Actions

Bug #62421

closed

Using array of constrains with "logicalAnd" or "logicalOR" results in strange nested queries

Added by Dennis Biedermann over 9 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Extbase
Target version:
-
Start date:
2014-10-23
Due date:
% Done:

0%

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

Description

If you collect a set of constrains within an array and try to combine those constraints with "logicalAnd" or "logicalOr", the result is a strange nested query.

Example

$customerConstraints = array(
    $query->equals('companyNo', 1),
    $query->equals('customerNo', 4711),
    $query->equals('customerAddrNo', 3)
);
$constraints = $query->logicalAnd($customerConstraints);

This should create a sql statement like:

... companyNo = '1' AND customerNo = '4711' AND customerAddrNo = '3'

but instead the result is something like this:

... (company_no = '1' AND customer_no = '9330') AND customer_addr_no = '0'

And it even gets worse if you add more constrains or try to combine different constraint sets with another "logicalAnd" or "logicalOr":
Here's a live example

        (
            (
                (
                    (
                        (
                            last_name LIKE '%Bier%' OR middle_name LIKE '%Bier%'
                        ) OR
                        first_name LIKE '%Bier%'
                    )
                    OR
                    street LIKE '%Bier%'
                )
                OR zip LIKE '%Bier%'
            )
            OR
            city LIKE '%Bier%'
        ) AND
        (
            (
                (    
                    (
                        last_name LIKE '%Hund%' OR middle_name LIKE '%Hund%'
                    ) OR
                    first_name LIKE '%Hund%'
                )
                OR
                street LIKE '%Hund%'
            ) OR
            zip LIKE '%Hund%'
        ) OR
        city LIKE '%Hund%'
    )
)

This is the result of simple addition of two constraint array with "logicalOr".

IMHO this is a crucial bug and should be fixed ASAP.


Files

dump1.png (53.4 KB) dump1.png Dennis Biedermann, 2014-10-23 12:46
Actions #1

Updated by Dennis Biedermann over 9 years ago

This is the simplified code for the live example:

$constraintsSet = array(
    array(
        $query->like('lastName', '%Bier%'),
        $query->like('middleName', '%Bier%'),
        $query->like('firstName', '%Bier%'),
        $query->like('street', '%Bier%'),
        $query->like('zip', '%Bier%'),
        $query->like('city', '%Bier%')
    ),
    array(
        $query->like('lastName', '%Hund%'),
        $query->like('middleName', '%Hund%'),
        $query->like('firstName', '%Hund%'),
        $query->like('street', '%Hund%'),
        $query->like('zip', '%Hund%'),
        $query->like('city', '%Hund%')
    )
);
$constraints = $query->logicalOr($constraintsSet[0], $constraintsSet[1]);
$query->matching($constraints);
Actions #2

Updated by Mathias Schreiber about 6 years ago

  • Status changed from New to Needs Feedback

can you cross check if this is still the case with the move to doctrine in v8?

Actions #3

Updated by Alexander Opitz almost 6 years ago

  • Status changed from Needs Feedback to Closed

No feedback within the last 90 days => closing this issue.

If you think that this is the wrong decision or experience this issue again, then please write to the mailing list typo3.teams.bugs with issue number and an explanation or open a new ticket and add a relation to this ticket number.

Thank you and best regards

Actions

Also available in: Atom PDF