#6041: Model->find "NOT" does not work as expected
---------------------------+------------------------------------------------
Reporter: datac0re | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: Model
Version: 1.2 Final | Severity: Normal
Keywords: Model NOT | Php_version: PHP 5
Cake_version: 1.2.0.7962 |
---------------------------+------------------------------------------------
In 1.2.0.7962 when crafting the following conditions, the generated SQL
does not match with what I would expect. Maybe this is a bug, maybe it's
by design, but if it is by design, I feel that the behavior is counter-
intuitive and may cause people to not get what they are looking for (it
happened to me!).
Example:
$model->find('all', array(
'conditions' => array(
'id >' => 25
'NOT' => array(
'src' => '',
'lastapp' => 'MeetMe'
)
)
));
I would expect the SQL to generate the following:
1. WHERE id > 25 AND NOT (src = '' and lastapp = 'MeetMe')
instead, this is what is generated:
2. WHERE id > 25 AND (NOT (`src` = '') AND NOT (`lastapp` = 'MeetMe'))
The two statements are NOT equal (i.e. the NOT operator isn't
distributive)
See the following tests:
Ex 1:
src = ''
lastapp = 'MeetMe'
Query 1: NOT (TRUE and TRUE) = FALSE
Query 2: NOT (TRUE) and NOT (TRUE) = FALSE
Ex 2:
src = 'anything'
lastapp = 'MeetMe'
Query 1: NOT (FALSE AND TRUE) = TRUE
Query 2: NOT (FALSE) and NOT (TRUE) = FALSE
Ex 3:
src = ''
lastapp = 'anything'
Query 1: NOT (TRUE AND FALSE) = TRUE
Query 2: NOT (TRUE) and NOT (FALSE) = FALSE
Ex 4:
src = 'anything'
lastapp = 'anything
Query 1: NOT (FALSE AND FALSE) = TRUE
Query 2: NOT (FALSE) and NOT (FALSE) = TRUE
Example 2 and 4 show that the statements are not equal. I've verified it
by also doing both versions of the queries and getting counts back that
differ.
--
Ticket URL: <https://trac.cakephp.org/ticket/6041>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---