UnionOfRAD/lithium — Issue #335: find() with 'list' using SQL's DISTINCT returns an empty array.
Author: housni
Created: 2012-02-15 11:52:50+00:00
State: open

models/MyModels.php:

array('type' => 'integer',
'key' => 'primary'),
'title' => array('type' => 'varchar')
);
}
?>

controllers/MyModelsController.php

array('id', 'title'),
)
);
return compact('myModels');
}
}
?>

The above example works as expected. MyModelsController::index() yields an array whose key is the `id` field and value is the `title` field.

However, if you add the SQL's `DISTINCT` to the list finder, it returns an empty array.

Eg: I changed this:
```'fields' => array('id', 'title'),```
to:
```'fields' => array('DISTINCT id, title'),```
and I get an empty array.

It makes sense that it doesn't work since we are supplying fields as one argument and Lithium can't distinguish between the fields and the DISTINCT keyword so it would be nice to have the option to specify distinct fields. Perhaps something like this:

'fields' => array('distinct' => array('id', 'title'))

Completely in love with the framework, so far.
Thanks,
- Housni.