propelorm/Propel — pull request #492 by andrea-chris (2012-10-25 13:38:56+00:00)
Title: Fixed problem about datetime on primary keys

If you have a datetime type on a primary key, when you generate a key for pool you obtained:

ERROR: Catchable Fatal Error: Object of class DateTime could not be converted to string in ... line ...

It's occurs because it tries to convert pk to string before serialize.

The generated code tries to do something like this (example):

serialize(array( (string) $obj->getDate()));

But php DateTime object can't cast to string. I have changed the code generator to avoid doing casting. This way it works for every data type on primary keys. The new generated code is something like this (fixed example):

serialize(array( (string) ($obj->getDate() instanceof \DateTime) ? $obj->getDate()->format('r') : $obj->getDate()));