Nanne Huiges
Fri Jan 20 06:09:45 -0500 2012
The issue seems to come from the function
1 assign_attribute($name,$value)
This function decides if 'cast' should be called on the value, on the basis of the $name being present as a key in the "$table->columns" array.
The name is the 'inflected' name, but the array_keys are the origional table-column names.
Possible sollutions might be:- make the keys of the columns->table the inflected name (don't know what effect that might have, we might need to call 'lower' on some fields)
- fix the function to check the inflected name if the key is not found like so.
1 if (array_key_exists($name,$table->columns) && !is_object($value)){
2 $value = $table->columns[$name]->cast($value,static::connection());
3 }else{//new check: maybe the $name is inflected.
4 $col = $table->get_column_by_inflected_name($name);
5 if (!is_null($col) && !is_object($value)){
6 $value = $col->cast($value,static::connection());
7 }
8 }
(1-1/1)
Subject: Date object vs string depending on capitalizaion?
I have seen below behaviour, and I don't really know where it comes from, if this is a deliberate case (I hope not) and or if someone knows a patch:
A date/datetime field in the database gets converted to a DateTime object, but NOT if the columname has a capital.
This means that if I do this:
And make an object out of it, I get 1 string for testDate1, and one ActiveRecord\DateTime Object. Same will not happen if I make the first column all lowercase.
This is kinda tricky if I want to use a AR-model, because I need to decide if I have to do '->format()' or can't.