[MODM-93] YAML and XML mapping drivers ignore discriminatorField and discriminatorMap Created: 24/Oct/10 Updated: 24/Nov/10 Resolved: 24/Nov/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 1.0.0ALPHA1, 1.0.0ALPHA2, 1.0.0BETA1, 1.0.0BETA2 |
| Fix Version/s: | 1.0.0ALPHA1, 1.0.0ALPHA2, 1.0.0BETA1, 1.0.0BETA2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Dan Ordille | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Symony2 |
||
| Description |
|
The discriminatorField and discriminatorMap options are ignored by both the YAML and XML drivers. Example: <?xml version="1.0" encoding="UTF-8"?> <doctrine-mongo-mapping> <document name="Application\Test\Document\Group" collection="groups"> <field name="id" fieldName="id" id="true" /> <field name="name" fieldName="name" type="string" /> <embed-many field="people" discriminator-field="type"> <discriminator-map> <discriminator-mapping class="Admin" value="Admin" /> <discriminator-mapping class="User" value="User" /> </discriminator-map> </embed-many> </document> </doctrine-mongo-mapping> I think that this is also a problem for referenced documents as well, as the code for the two is nearly identical. I refactored addEmbedMapping and addReferenceMapping to call the same function addDocumentMapping |
| Comments |
| Comment by Jonathan H. Wage [ 24/Nov/10 ] |
|
Merged! Thanks for the fix! |
[MODM-50] GridFs file classes don't support inheritance Created: 17/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
GridFs files do not support inheritance anymore. This issue only appeared after latest updates from git. It was working before. Here is a test case: /** * @Document(collection="files", db="tests") * @InheritanceType("SINGLE_COLLECTION") * @DiscriminatorField(fieldName="type") * @DiscriminatorMap({ * "file"="file", * "image"="image" * }) */ class file { /** @Id */ protected $id; /** @File */ protected $file; function __construct($file) {$this->file = $file;} } /** @Document(collection="files", db="tests") */ class image extends file { /** @File */ protected $file; } $a = new image(__DIR__ . '/test.txt'); $dm->persist($a); $dm->flush(); This code creates document in regular collection "files" instead of GridFs collection. |
| Comments |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
Thanks for the issue! Fixed by http://github.com/doctrine/mongodb-odm/commit/3830635986a288235c46e198b7170d959ce37647 |
| Comment by Vladimir Razuvaev [ 17/Aug/10 ] |
|
Thanks for quick fixes! I also found other weird issue, will create separate case for it. |
[MODM-49] Getting PHP notice and warning with empty persistent collection Created: 17/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Collections |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
If there is an object with empty collection, e.g.: {
"_id": "4c6a11810f9d503c03000000",
"b": [
]
}
Then following code produces notice and warning: /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @ReferenceMany(targetDocument="b", cascade="persist") */ protected $b; function getB() {return $this->b;} } /** @Document(db="tests", collection="tests2") */ class b { /** @Id */ protected $id; } $a = $dm->loadByID('a', '4c6a11810f9d503c03000000'); echo count($a->getB()); // produces notice and warning Notice and warning text: Notice: Undefined variable: groupedIds in library\Doctrine\ODM\MongoDB\PersistentCollection.php on line 122
Warning: Invalid argument supplied for foreach() in library\Doctrine\ODM\MongoDB\PersistentCollection.php on line 122
|
| Comments |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
This is fixed now. |
[MODM-48] Embedded document changes are ignored if it was empty before Created: 16/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Persister |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Imaging the object in DB: {
"_id": "4c693f9f0f9d501c0d000000",
"b": [
]
}
Then following code fails to update property "b": /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @EmbedOne(targetDocument="b", cascade="all") */ protected $b; function getId() {return $this->id;} function getB() {return $this->b;} function setB($b) {$this->b = $b;} } /** @EmbeddedDocument */ class b { /** @String */ protected $val; function setVal($val) {$this->val = $val;} function getVal() {return $this->val;} } $a = $dm->loadByID('a', '4c693f9f0f9d501c0d000000'); $a->getB()->setVal('test'); $dm->persist($a); $dm->flush(); $dm->getUnitOfWork()->clear(); $a = $dm->loadByID('a', $a->getId()); $c = ('test' === $a->getB()->getVal()); var_dump($c); // expecting "true", but outputs false |
| Comments |
| Comment by Jonathan H. Wage [ 16/Aug/10 ] |
|
Are you using the most recent version of mongo in git? |
| Comment by Vladimir Razuvaev [ 16/Aug/10 ] |
|
Yes, just updated to today's version from git - got same results. |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
Thanks for the issue! Fixed by http://github.com/doctrine/mongodb-odm/commit/c57cc9fbf279918edcafd03ab4562ed33b467323 |
[MODM-47] @AlsoLoad annotation, used on method causes fatal error Created: 16/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Getting following errors when using @AlsoLoad annotation on method: Notice: Undefined index: isCascadePersist in library\Doctrine\ODM\MongoDB\UnitOfWork.php on line 1661 Notice: Undefined index: fieldName in library\Doctrine\ODM\MongoDB\UnitOfWork.php on line 362 Notice: Undefined index: in library\Doctrine\ODM\MongoDB\Mapping\ClassMetadata.php on line 923 Fatal error: Call to a member function getValue() on a non-object in library\Doctrine\ODM\MongoDB\Mapping\ClassMetadata.php on line 923 Test Case: /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @String */ protected $b = 'tmp'; /** @AlsoLoad("c") */ function renameC($c) {$this->b = $c;} function getId() {return $this->id;} } $a = new a(); $dm->persist($a); $dm->flush(); $dm->getUnitOfWork()->clear(); $a = $dm->loadByID('a', $a->getId()); |
| Comments |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
Thanks for all the issues Fixed here http://github.com/doctrine/mongodb-odm/commit/6e7610ac99dcc4cab92cd01bd66e0a2c9ffda1ce |
[MODM-46] @AlsoLoad annotation causes exception when used together with Embed/Reference annotations Created: 16/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Imagine that there is following object in DB: {
"_id": "4c6936bf0f9d50300d000000",
"c": {
"tmp": "tmp"
}
}
And I want to rename property "c" to "b" in my class, using @AlsoLoad together with @EmbedOne /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** * @EmbedOne(targetDocument="b") * @AlsoLoad("c") */ protected $b; } /** @EmbeddedDocument */ class b { protected $tmp = 'tmp'; } $a = $dm->loadByID('a', '4c6936bf0f9d50300d000000'); // will throw an exception: Property "b" in "a" was already declared, but it must be declared only once |
| Comments |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
Fixed by http://github.com/doctrine/mongodb-odm/commit/166ca49c13c8e3132b85383e4c55f0a09ce0d2b1 |
[MODM-45] Doctrine doesn't persist empty objects Created: 16/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Persister |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Doctrine won't persist object if it is empty (all fields are nulls). Not sure if it is bug or expected behavior, but sometimes it causes inconvenience. Test case: /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @String */ protected $b; } $a = new a(); $dm->persist($a); $dm->flush(); // $a won't be inserted There is also related issue: when embedding empty object (all fields are nulls) embedded object is not saved. /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @String */ protected $tmp = 'WorkaroundToBeSaved'; /** @EmbedOne(targetDocument="b", cascade="all") */ protected $b; function getId() {return $this->id;} function getB() {return $this->b;} function setB($b) {$this->b = $b;} } /** @EmbeddedDocument */ class b { /** @String */ protected $val; function setVal($val) {$this->val = $val;} function getVal() {return $this->val;} } $a = new a(); $a->setB(new b()); $dm->persist($a); $dm->flush(); $dm->getUnitOfWork()->clear(); $a = $dm->loadByID('a', $a->getId()); $c = (null !== $a->getB()); var_dump($c); // returns false, while expecting true |
| Comments |
| Comment by Jonathan H. Wage [ 16/Aug/10 ] |
|
Mongo won't let you insert empty documents, so we can't allow it. |
| Comment by Jonathan H. Wage [ 16/Aug/10 ] |
$mongo = new Mongo();
$doc = array();
$mongo->dbname->coll->insert($doc);
Causes this error: PHP Fatal error: Uncaught exception 'MongoException' with message 'no elements in doc' in /Users/jwage/Sites/mongodb-odm/test.php:5
Stack trace:
#0 /Users/jwage/Sites/mongodb-odm/test.php(5): MongoCollection->insert(Array)
#1 {main}
thrown in /Users/jwage/Sites/mongodb-odm/test.php on line 5
MongoException: no elements in doc in /Users/jwage/Sites/mongodb-odm/test.php on line 5
Call Stack:
0.0004 320216 1. {main}() /Users/jwage/Sites/mongodb-odm/test.php:0
0.0037 322036 2. MongoCollection->insert() /Users/jwage/Sites/mongodb-odm/test.php:5
|
| Comment by Vladimir Razuvaev [ 16/Aug/10 ] |
|
I see now. But second case is still possible with mongo and not supported by ODM: $a = new a(); $a->setB(new b()); $dm->persist($a); $dm->flush($a); /* expecting: { "_id": "4c69ff3c0f9d50c80e000000", "tmp": "WorkaroundToBeSaved", "b" => [] } * getting: { "_id": "4c69ff3c0f9d50c80e000000", "tmp": "WorkaroundToBeSaved" } */ Also, if I remove string "WorkaroundToBeSaved" from $a, it won't be saved with flush, although it is not empty (has $b field set). |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
This is expected as well since we never store null values or empty arrays. |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
After a second look we can fix this. |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
Fixed by http://github.com/doctrine/mongodb-odm/commit/b3a16496c0576e8f926faec9bbcfd5716006273b |
[MODM-43] Explicit schema migration Created: 10/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Hydration |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | New Feature | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Currently supported ways of schema migration are sufficient in many cases. But I think it's worth considering to have more explicit way to migrate schema for better readability / code maintenance. It might be useful to be able to transform original MongoDb data prior to hydration. Maybe as a new lifecycle callback (e.g. preLoad). This way one could have special property for schema version in the document and normalize data according to version differencies. e.g.: function preLoad(array &$data)
{
if(!isset($data['version'])) {
$data['version'] = 1;
}
switch($data['version']) {
case 1:
$data['fullName'] = $data['name'];
unset($data['name']);
// breaks are ommitted intentionally here and below
case 2:
$e = explode(' ', $data['fullName'])
$data['firstname'] = $e[0];
$data['lastname'] = $e[1];
unset($data['fullName']);
case 3:
$data['address'] = array(
'street' => $data['street'],
'city' => $data['city']
);
unset($data['street']);
unset($data['city']);
case 4:
default:
// current version
}
}
Just as example. It also simplifies writing tests for schema migrations as I think. Is it possible with current ODM internals? What do you think? |
| Comments |
| Comment by Jonathan H. Wage [ 10/Aug/10 ] |
|
I think this can be implemented already without having to change Doctrine. You just need to manage a version field and use the preLoad() like you are above. It is an acceptable idea, but I think it is already possible. What do you think? |
| Comment by Vladimir Razuvaev [ 11/Aug/10 ] |
|
It's great if it is already possible. But I think there is no "preLoad", "preHydrate" or similar event right now. At least I didn't find one in code or docs. |
| Comment by Jonathan H. Wage [ 11/Aug/10 ] |
|
Ok, I think maybe we can add a preLoad() event. |
| Comment by Jonathan H. Wage [ 17/Aug/10 ] |
|
Fixed by http://github.com/doctrine/mongodb-odm/commit/78fefc3b70aa8ec0facd3cc4ffa27d6c88670407 |
[MODM-42] PersistentCollection fails when working with MongoGridFs Created: 10/Aug/10 Updated: 17/Aug/10 Resolved: 17/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Collections |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Getting following error when trying to use MongoGridFs files with referenceMany: Argument 2 passed to Doctrine\ODM\MongoDB\UnitOfWork::getOrCreateDocument() must be an array, object given, called in D:\Work\www\syter2.localhost.dev\library\Doctrine\ODM\MongoDB\PersistentCollection.php on line 110 and defined D:\Work\www\syter2.localhost.dev\library\Doctrine\ODM\MongoDB\UnitOfWork.php:1719 As far as I understand queries against MongoGridFS collection return instances of MongoGridFSFile, while PersistentCollection only expects arrays (as with regular collections) I think Issue appeared after latest updates from git. Because I didn't experience it with ALPHA1 (didn't test with ALPHA2) |
| Comments |
| Comment by Jonathan H. Wage [ 10/Aug/10 ] |
|
I'll check it out, if you can provide a test that'd be helpful. |
| Comment by Vladimir Razuvaev [ 10/Aug/10 ] |
|
Here is a test case: /** @Document(db="tests", collection="tests") */ class a { /** @Id */ protected $id; /** @ReferenceMany(targetDocument="file") */ protected $files = array(); function __construct($files) {$this->files = $files;} function getFiles() {return $this->files;} } /** @Document(db="tests", collection="files") */ class file { /** @Id */ protected $id; /** @File */ protected $file; function __construct($path) {$this->file = $path;} function getMongoFile() {return $this->file;} } $f = new file(__DIR__ . '/test.txt'); $a = new a(array($f)); $dm->persist($f); $dm->persist($a); $dm->flush(); $dm->getUnitOfWork()->clear(); $a = $dm->findOne('a', array()); foreach($a->getFiles() as $file) { $file->getMongoFile(); // produces catchable fatal error } |
| Comment by Jonathan H. Wage [ 10/Aug/10 ] |
|
Fixed in http://github.com/doctrine/mongodb-odm/commit/964ce247841d11af8ab28cfbde36f6cc09b0d366 |
[MODM-41] Hydration down not work for annotation "@ReferenceMany" Created: 06/Aug/10 Updated: 09/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Hydration |
| Affects Version/s: | 1.0.0ALPHA2 |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Flavio Lacerda | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows(webserver) / Unix (Mongo) |
||
| Attachments: |
|
| Description |
|
When you try to find or execute query, filds with annotation reference many (arrays) do not load. Example: user.php <?php /** * @Document(db="DB", collection="Users") */ class User { /** * @Id */ public $id; /** * @String */ public $name; /** * @String */ public $password; /** * @String */ public $email; /** * @ReferenceMany(targetDocument="Group") */ public $groups = array(); } ?> group.php <?php /** * @Document(db="MCI", collection="Groups") */ class Group { /** * @Id */ public $id; /** * @String */ public $name; /** * @String */ public $role_name; } ?> When you execute this line: $obj = $this->dm->findOne("User",("name" => "Flavio")); All the fields are returned correctly, but "groups" apear empty. When you use @EmbedMany annotation works file. Regards. PS: I'm using codeigniter framework |
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
This works for me. Can you provide a more exact test case that does not work? |
| Comment by Flavio Lacerda [ 06/Aug/10 ] |
|
I created an script. |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
http://github.com/doctrine/mongodb-odm/commit/cbe22dfd50225250ab468ea2f5e243736b2f35fd |
| Comment by Flavio Lacerda [ 09/Aug/10 ] |
|
Now works perfect. I´m using it a lot. Amazing lib and amazing support. |
[MODM-40] Move value scalarization and comparison to Unit Of Work Created: 06/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Persister, UnitOfWork |
| Affects Version/s: | 1.0.0ALPHA1, 1.0.0ALPHA2 |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Task | Priority: | Major |
| Reporter: | Bulat Shakirzyanov | Assignee: | Bulat Shakirzyanov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The BasicDocumentPersister::_equals belongs in the UnitOfWork. |
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
I refactored and that code is not needed and gone now. |
[MODM-38] Using YAML description with embedMany causes PHP notice error Created: 04/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 1.0.0ALPHA2 |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sebastian Hoitz | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
When using the YAML style description together with the new embedMany functionality of mixed documents, you get a PHP notice error every time you create a new model. Because when you have mixed documents, you don't specify a targetDocument, and therefore the YAML Driver can not find an element in the array that describes the targetDocument. |
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
http://github.com/doctrine/mongodb-odm/commit/8c8437a9113a0849f38db0664f66dd407a497918 |
[MODM-37] Problems with EmbedMany and discrimatorMap and discriminatorField Created: 04/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | 1.0.0ALPHA1 |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sebastian Hoitz | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I'm experiencing a problem when trying to embed documents and specify my own discriminatorMap and Field. This is the code I have: /** @Document(collection = "ticket") */ class App_Model_Ticket extends App_Model_Abstract { /** * @EmbedMany( * discriminatorField = "type", * discriminatorMap={ * "twitter"="App_Model_Ticket_Twitter", * "email"="App_Model_Ticket_Email" * }) */ protected $messages = array(); // [...] } App_Model_Abstract is a MappedSuperClass. App_Model_Ticket_Email and App_Model_Ticket_Twitter pretty much look alike right now: /** @EmbeddedDocument */
class App_Model_Ticket_Email extends App_Model_Ticket_Message
{
}
and App_Model_Ticket_Message is another MappedSuperClass that extends App_Model_Abstract. Now, whenever I create a new model and persist it to mongoDB, the entry gets created and looks like this: [_id] => MongoId Object ( ) [messages] => Array ( [0] => Array ( [message] => Lorem ipsum [subject] => Ich bin ein Berliner22 [dateSent] => MongoDate Object ( [sec] => 1280909855 [usec] => 0 ) [_doctrine_class_name] => App_Model_Ticket_Twitter ) [1] => Array ( [message] => Lorem ipsum [subject] => Ich bin ein Berliner22 [dateSent] => MongoDate Object ( [sec] => 1280909855 [usec] => 0 ) [_doctrine_class_name] => App_Model_Ticket_Email ) ) [subject] => Ich bin ein Berliner22 [dateCreated] => MongoDate Object ( [sec] => 1280909855 [usec] => 0 ) [dateLastMessage] => MongoDate Object ( [sec] => 1280909855 However, as you can see no type field for my embedded documents, it still uses _doctrine_class_name. But when I try to fetch this object, I get an exception saying "Class not found". I think this is because right now Doctrine ODM does not write into the custom discriminatorField with embedded documents, but reads from it. |
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
http://github.com/doctrine/mongodb-odm/commit/618896bb8d879a8365dc359a8949c9d2cad5bec7 |
[MODM-36] Embedded relations are not persisted after a flush() Created: 03/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Pablo Godel | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Newly added embedded relations do not get persisted when a flush() is executed before they are added to the parent document. Here is a failing test, note the comment "// Adding this flush here makes level1 not to be inserted.": public function testFlushEmbedded() { $test = new EmbeddedTestLevel0(); $test->name = 'test'; $this->dm->persist($test); $this->dm->flush(); $this->dm->clear(); $test = $this->dm->findOne('Documents\Functional\EmbeddedTestLevel0'); $this->assertInstanceOf('Documents\Functional\EmbeddedTestLevel0', $test); // Adding this flush here makes level1 not to be inserted. $this->dm->flush(); $level1 = new EmbeddedTestLevel1(); $level1->name = 'test level1 #1'; $test->level1[] = $level1; $this->dm->persist($test); $this->dm->flush(); $this->dm->clear(); $test = $this->dm->findOne('Documents\Functional\EmbeddedTestLevel0'); $this->assertInstanceOf('Documents\Functional\EmbeddedTestLevel0', $test); $this->assertInstanceOf('Documents\Functional\EmbeddedTestLevel1', $test->level1[0]); } |
| Comments |
| Comment by Vladimir Razuvaev [ 06/Aug/10 ] |
|
I also experience this issue. Formatted text from original message for convenience: public function testFlushEmbedded() { $test = new EmbeddedTestLevel0(); $test->name = 'test'; $this->dm->persist($test); $this->dm->flush(); $this->dm->clear(); $test = $this->dm->findOne('Documents\Functional\EmbeddedTestLevel0'); $this->assertInstanceOf('Documents\Functional\EmbeddedTestLevel0', $test); // Adding this flush here makes level1 not to be inserted. $this->dm->flush(); $level1 = new EmbeddedTestLevel1(); $level1->name = 'test level1 #1'; $test->level1[] = $level1; $this->dm->persist($test); $this->dm->flush(); $this->dm->clear(); $test = $this->dm->findOne('Documents\Functional\EmbeddedTestLevel0'); $this->assertInstanceOf('Documents\Functional\EmbeddedTestLevel0', $test); $this->assertInstanceOf('Documents\Functional\EmbeddedTestLevel1', $test->level1[0]); } |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
Do you all have the cascade operating enabled in your mapping? |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
Fixed in http://github.com/doctrine/mongodb-odm/commit/20033a35a9cbf345636defdaaaa57204bae8fbab |
[MODM-35] Proxy item gets reset on persistent collection load if that item was in the collection Created: 02/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | None |
| Affects Version/s: | 1.0.0ALPHA2 |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Bulat Shakirzyanov | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
http://github.com/doctrine/mongodb-odm/commit/236d4c6fad228f281a6fff9979c5fdc3773969e1 |
[MODM-34] Custom Id always gets sent with changeset Created: 02/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | UnitOfWork |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Bulat Shakirzyanov | Assignee: | Bulat Shakirzyanov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Whenever the Unit of Work computes the changeset for a document with custom id, the id attribute always gets sent. |
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
http://github.com/doctrine/mongodb-odm/commit/ad8a7821bd176e875b9ec1f756c32a15eed31fb3 |
[MODM-33] Class-level annotations are ignored if set on MappedSuperclass Created: 02/Aug/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | None |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Vladimir Razuvaev | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Class-level annotations: @HasLifecycleCallbacks, @InheritanceType, @DiscriminatorField, @DiscriminatorMap have no effect when defined on @MappedSuperclass You must explicitly set @HasLifecycleCallbacks for every document class to make callback work. As for inheritance annotations, you have to copy-paste all annotations to all document classes to make it work. Simple example: /** * @MappedSuperclass * @HasLifecycleCallbacks */ abstract class a { /** @String */ protected $a = ''; /** @PrePersist */ function prePersist() {$this->a = 'a';} } /** @Document(db="tests",collection="tests") */ class b extends a {} $b = new b(); $dm->persist($b); $dm->flush($b); With this example prePersist won't be called. Not sure if it is bug or expected behavior, but it adds some inconvenience, especially with inheritance mapping. |
| Comments |
| Comment by Jonathan H. Wage [ 02/Aug/10 ] |
|
This appears to work for me. I tested it here http://github.com/doctrine/mongodb-odm/commit/af9aa0f674f8b542c89f8c975ac403fd46f6e29e |
| Comment by Vladimir Razuvaev [ 02/Aug/10 ] |
|
Hi, looks like it affected ALPHA1. Also, want to thank you and other committers for ODM project. It is really cool! |
| Comment by Vladimir Razuvaev [ 05/Aug/10 ] |
|
Looks like issue still exists for inheritance. At least following test case doesn't work for me on the latest version from git: /** * @MappedSuperClass * @InheritanceType("SINGLE_COLLECTION") * @DiscriminatorField(fieldName="type") * @DiscriminatorMap({ * "b"="b", * "c"="c" * }) */ abstract class a { /** @String */ protected $a = ''; } /** @Document(db="tests",collection="tests") */ class b extends a {} /** @Document(db="tests",collection="tests") */ class c extends a {} $b = new b(); $dm->persist($b); $dm->flush($b); New document will be created without "type" field. It works properly only if I copy-paste all annotations to every document class (b, c, etc). |
| Comment by Jonathan H. Wage [ 05/Aug/10 ] |
|
I don't think that is supposed to work. Try removing the @MappedSuperclass annotation. |
| Comment by Vladimir Razuvaev [ 05/Aug/10 ] |
|
Removing @MappedSuperClass didn't help, but adding @Document annotation on abstract class did (it also allows to remove @Document annotation on concrete classes). The main point was to avoid annotations duplication, so I think this solution works pretty well. But maybe worth mentioning in the documentation, because it is pretty common use case to have one abstract class and several subclasses within same collection. And it took some time for me to find out how that could be done. |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
Pretty sure it is fixed now. http://github.com/doctrine/mongodb-odm/commit/7ca29f25f7018b781183cf72082802ab4dcc567a |
[MODM-32] dbref $id persisted as string instead of objectid Created: 31/Jul/10 Updated: 06/Aug/10 Resolved: 06/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine MongoDB ODM |
| Component/s: | Persister |
| Affects Version/s: | 1.0.0ALPHA1, 1.0.0ALPHA2, 1.0.0BETA1 |
| Fix Version/s: | 1.0.0BETA1 |
| Type: | Bug | Priority: | Major |
| Reporter: | Bulat Shakirzyanov | Assignee: | Bulat Shakirzyanov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
A clone of http://github.com/doctrine/mongodb-odm/issues/issue/2/. |
| Comments |
| Comment by Jonathan H. Wage [ 06/Aug/10 ] |
|
http://github.com/doctrine/mongodb-odm/commit/935759b498a057d08652379fb8133bb238b23a18 |