Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Different behaviour of saving embed document #104

Open
quard8 opened this issue Nov 20, 2012 · 1 comment
Open

Different behaviour of saving embed document #104

quard8 opened this issue Nov 20, 2012 · 1 comment

Comments

@quard8
Copy link

quard8 commented Nov 20, 2012

I have my requirements

        'pls'   => array('DocumentSet'),
        'pls.$' => array('Document:Model_Playlist', 'AsReference'),

For example then I saving only "pls" document

$this->pls = new Shanty_Mongo_DocumentSet();
$this->pls->addDocument($playlist);
$this->pls->save();

Resulting JSON representation in DB will be

{
    "pls": {
        "0": {
            "$ref": "playlists",
            "$id": ObjectId("400000000000000000000001")
        }
    }
}

But when I will save all document via $this->save()

I will get

{
    "pls": [
        {
            "$ref": "playlists",
            "$id": ObjectId("400000000000000000000001")
        }
    ]
}

Seem's like a bug, but maybe I'm wrong?

@coen-hyde
Copy link
Owner

This is a known bug with Shany Mongo. It's caused by php munting the data types after first save. As in your dataset is getting saved as an array, pulled out as a document then resaved as a document. I'm going to try an fix this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants