Update query building in TranslateBehavior.

* Reduce duplicate checks for Alias.*.
* Allow both the quoted and non quoted version of Alias.*

Fixes #3210
This commit is contained in:
mark_story 2012-09-25 21:01:19 -04:00
parent 6818d69fc3
commit 0fc9a2c29c

View file

@ -147,11 +147,14 @@ class TranslateBehavior extends ModelBehavior {
if (empty($query['fields'])) {
$addFields = $fields;
} elseif (is_array($query['fields'])) {
$isAllFields = (
in_array($Model->alias . '.' . '*', $query['fields']) ||
in_array($Model->escapeField('*'), $query['fields'])
);
foreach ($fields as $key => $value) {
$field = (is_numeric($key)) ? $value : $key;
if (
in_array($Model->escapeField('*'), $query['fields']) ||
$isAllFields ||
in_array($Model->alias . '.' . $field, $query['fields']) ||
in_array($field, $query['fields'])
) {