jonathangeiger / kohana-jelly

See the link below for the most up-to-date code
https://github.com/creatoro/jelly
MIT License
146 stars 34 forks source link

Field_Expression seems to be broken #165

Open biakaveron opened 14 years ago

biakaveron commented 14 years ago
'test'  => new Field_Expression(array('column' => DB::expr('created + lifetime'))),

When I trying to access $model->test, I get an ErrorException "array_key_exists(): The first argument should be either a string or an integer", line#166 in Jelly_Meta_Core class. Manual datatype casting should helps.

lmb commented 13 years ago

I am still seeing this issue in the latest master checkout. Any chance this will be fixed?

biakaveron commented 13 years ago

It works in 'unstable' branch

lmb commented 13 years ago

I tried switching to the unstable branch and I still can't seem to get this to work. This is what I do:

$meta->fields(array(
   'id' => new Jelly_...,
   'first_name' => new Jelly_Field_String,
   'last_name' => new Jelly_Field_String,
   'name' => new Jelly_Field_Expression(array(
       'column' => DB::expr("CONCAT(`first_name`, ' ', `last_name`)")
   ))
));

This is pretty much the example code. This is where it breaks:

Jelly::query('contributor')
   ->select_colum(array('name'))
   ->select();

When running the code I get the following error message:

Database_Exception [ 1054 ]: Unknown column 'name' in 'field list' [ SELECT `name` FROM `contributors` AS `contributors` ]

Apparently expression fields are not properly aliased into a "expression AS name" statement? Or is there anything I am doing wrong?