Closed drock closed 12 years ago
I was playing around with this branch locally, since I need the same functionality, and I found that $n within values of the arrays does not evaluate, as I would expect.
For example, with the following code:
$phactory->define('user', array(
'_id' => '$n',
'name' => 'John Doe $n',
'tags' => array(
'one$n',
'two$n',
'three$n'
)
));
I expect a MongoDB data structure that looks something like this:
{
"_id" : 0,
"name" : "John Doe 0",
"tags" : [
"one0",
"two0",
"three0"
]
}
But, instead, I get a data structure that looks like this:
{
"_id" : 0,
"name" : "John Doe 0",
"tags" : [
"one$n",
"two$n",
"three$n"
]
}
Good catch, the eval that interpreted the $n was not applied recursively originally and now needs to be since we can have arrays as data values.
Looks good. Thanks!
Any chance of this getting merged in?
:+1: from me on this!
Merged, tagged, etc.
On Tue, Nov 6, 2012 at 12:13 PM, Ben Ramsey notifications@github.comwrote:
[image: :+1:] from me on this!
— Reply to this email directly or view it on GitHubhttps://github.com/chriskite/phactory/pull/24#issuecomment-10121061.
The _evalSequence function of the Blueprint class forces all values of documents to be a string. This pull request adds a check to that so that if a value is not a string it won't be eval'd.
This is needed because as Phactory stands now, there is no way to create a document with a value being an array of scalars such as
In the above case an embedded document does not work as you end up with an array of nested arrays otherwise.