From 5035613157cd027cb4cbfebc88f1b05c12f231b0 Mon Sep 17 00:00:00 2001 From: Wouter van Dongen Date: Fri, 14 Mar 2014 15:20:12 +0100 Subject: [PATCH] * Fixed bug where select query in deleteAll could return wrong table name. PDOStatement::getColumnMeta (in mysql.php) sometimes returns the actual table name when using a MySQL view with the distinct select query, and not the alias table name. By returning the actual table name the records could not be removed. By the way PDOStatement::getColumnMeta is an experimental function, perhaps it's better to avoid it. --- lib/Cake/Model/Model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index c990c87eb..209b3e7c9 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2703,8 +2703,9 @@ class Model extends Object implements CakeEventListener { } $ids = $this->find('all', array_merge(array( - 'fields' => "DISTINCT {$this->alias}.{$this->primaryKey}", + 'fields' => "{$this->alias}.{$this->primaryKey}", 'order' => false, + 'group' => "{$this->alias}.{$this->primaryKey}", 'recursive' => 0), compact('conditions')) );