kla/php-activerecord — pull request #188 by NanneHuiges (2012-03-14 14:56:04+00:00)
Title: DateTime object casting for capitalized fields

If you have a capitalized field, it doesn't get called trough "cast", so it stays a string.

A simple edit to check that when the array-key doesn't exist, maybe the inflected name does.

I've even written a test for it, but bear with me because I'm not very well known with phpunit or the defaults of how to work with a database in it. I've changed the definition of the authors table to be able to test something:
With this you see that without the changed model you'll get an error (some_Date is a string, and not an object), and with the changed model the test runs fine.

CREATE TABLE authors(
author_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
parent_author_id INT,
name VARCHAR(25) NOT NULL DEFAULT 'default_name',
updated_at datetime,
created_at datetime,
some_Date date,
some_time time,
some_text text,
some_enum enum('a','b','c'),
encrypted_password varchar(50),
mixedCaseField varchar(50)
) ENGINE=InnoDB;