Bug #62421
closedUsing array of constrains with "logicalAnd" or "logicalOR" results in strange nested queries
0%
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
Updated by Dennis Biedermann about 10 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);
Updated by Mathias Schreiber almost 7 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?
Updated by Alexander Opitz over 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