Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Updated test case for bug in casting subobject arrays #471

Merged
merged 1 commit into from May 21, 2012

Conversation

Projects
None yet
3 participants
Contributor

nealerickson commented May 20, 2012

Added a new test case and modified the $_schema so that I could test type casting arrays of subobjects. The documents are being saved, however the values being saved to the db are not cast properly.

Ideally the following schema would allow me to properly cast an array of subobjects at the accounts path.

protected $_schema = array(
    '_id' => array('type' => 'id'),
    'accounts' => array('type' => 'object', 'array' => true),
    'accounts._id' => array('type' => 'id'),
    'accounts.name' => array('type' => 'string'),
    'accounts.created' => array('type' => 'date'),
);

However, when saving the following data the values in account arrays are not being properly cast. The _id fields remain strings while the created fields are numeric timestamps and not instances of MongoDate.

$data = array(
      '_id' => '4c8f86167675abfabd970300',
      'accounts' => array(array(
              '_id' => "4fb6e2dd3e91581fe6e75736",
              'name' => 'Foo',
              'created' => time()
          ),array(
              '_id' => "4fb6e2df3e91581fe6e75737",
              'name' => 'Bar',
              'created' => time()
          )                
      )
);

Ran the changes through li3_qa and everything passed. Looks like my editor was breaking out my tabs into spaces on my last commit.

Owner

nateabele commented May 21, 2012

Looks great, thanks much!

@nateabele nateabele merged this pull request into UnionOfRAD:data May 21, 2012

Contributor

jails commented May 23, 2012

The pull request 473 should solve this issue.

nateabele added a commit that referenced this pull request May 23, 2012

Merge pull request #473 from jails/data
Bug in casting subobject arrays solve #471
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment