find all fields (*) with some extra #558

Closed
hans-d opened this Issue Jun 24, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@hans-d
Contributor

hans-d commented Jun 24, 2012

Using the fields key in a find to return a SQL function output works fine. However, when all fields from a model are required and some functions, it is not possible to specify '*'. The generated SQL is fine, but the returned data is not mapped to the entities. but you get the right amount of (empty) entities...

Works: Model::first(array('fields' => array('field1', 'CASE field1 WHEN "" THEN true ELSE false END as check'));

Does not work: Model::first(array('fields' => array('*', 'CASE field1 WHEN "" THEN true ELSE false END AS check'));

Prefixing the '*' with the Model name / alias does not work.

The only workaround is to do something like

$fields = array_keys(Model::schema());
$fields[] = 'CASE field1 WHEN "" THEN true ELSE false END AS check';
Model::first(array('fields' => $fields));

All within the MySQL context on master.

@nateabele

This comment has been minimized.

Show comment Hide comment
@nateabele

nateabele Jun 25, 2012

Owner

This gets into the somewhat deeper issue of mapping result sets, which you technically can do manually already, it's just not super straightforward. This is probably a longer-term enhancement.

Owner

nateabele commented Jun 25, 2012

This gets into the somewhat deeper issue of mapping result sets, which you technically can do manually already, it's just not super straightforward. This is probably a longer-term enhancement.

@hans-d

This comment has been minimized.

Show comment Hide comment
@hans-d

hans-d Jun 25, 2012

Contributor

If you can give some pointers...

Contributor

hans-d commented Jun 25, 2012

If you can give some pointers...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment