ichikaway/cakephp-mongodb — Issue #35: Strict type casting based on schema (when available)
Author: aaronpeterson
Created: 2011-10-22 07:09:04+00:00
State: open

I was thinking it might be a good idea to shy away from native PHP casting...a quick case being that all data posted from a form is interpreted by php as a string. Cake's (2.0 and probably before) DBOSource gets very loose about types toward the end of DBOSource::value() specifically with integers.

I think regardless of whether one uses cakephp-mongodb in schema mode or not, they're going to need to be explicit about types. Going by the Model::mongoSchema definition means I can pass juggling onto the DBOSource but it also means I know what my Model::find() result types are ahead of time. Win-win, I thought. Beats iterating over Model::data in every model, at least.

Just a quick start to illustrate what I mean...

https://github.com/aaronpeterson/cakephp-mongodb/commit/32c1a1f78058c62b70bff2aab1042b2704713001