#6274: [PATCH] CounterCache queries wrong with unconventional primaryKeys -----------------------------------------+---------------------------------- Reporter: phally | Type: Bug Status: new | Priority: Medium Milestone: 1.2.x.x | Component: Model Version: 1.2 Final | Severity: Normal Keywords: CounterCache, primaryKey | Php_version: n/a Cake_version: | -----------------------------------------+---------------------------------- First my apologies for filing this ticket without a test case. I haven't had time to make one, however I think the problem can be seen in the diff.[[BR]] [[BR]] The query I was expecting was:[[BR]] {{{ SELECT `Project`.`company_id` FROM `projects` AS `Project` WHERE `project_id` = 3 LIMIT 1 }}} [[BR]] The query I got was:[[BR]] {{{ SELECT `Project`.`company_id` FROM `projects` AS `Project` WHERE `id` = '3' LIMIT 1 }}} [[BR]] I traced it to line 1423 of model.php, here has 'id' been set hardcoded:[[BR]] {{{ 'conditions' => array('id' => $this->id), }}} [[BR]] It should be:[[BR]] {{{ 'conditions' => array($this->primaryKey => $this->id), }}} [[BR]] I have attached a patch to apply. No other testcases were affected by this patch, I checked. I ran all tests of the model core test group. There was one failing test, but that was there before I applied the patch.
-- Ticket URL: <https://trac.cakephp.org/ticket/6274> 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 tickets-cakephp@googlegroups.com To unsubscribe from this group, send email to tickets-cakephp+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/tickets-cakephp?hl=en -~----------~----~----~----~------~----~------~--~---