[MODM-180] @DiscriminatorField("type") was not working for me Created: 12/Feb/14  Updated: 10/Apr/14

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Michael Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Via nginx / mongodb (db version v2.0.4, pdfile version 4.5) I am using symfony2 (2.4.*) with

composer.json:
"php": ">=5.4.0",
"doctrine/mongodb-odm": "1.0.0-BETA9",
"doctrine/mongodb-odm-bundle": "3.0.x-dev",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"doctrine/data-fixtures": "1.0.*",
"gedmo/doctrine-extensions": "dev-wip-v2.4.0",



 Description   

According to the current documentation http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/annotations-reference.html#discriminatorfield it is

 
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
 * @MongoDB\Document
 * @MongoDB\InheritanceType("SINGLE_COLLECTION")
 * @MongoDB\DiscriminatorField("type")
 */
class SuperUser
{
    // ...
}

and I got the following exception

 
[MongoException] zero-length keys are not allowed, did you use $ with double quotes?

which was hard to track down in the first place, as there is no useful stack trace showed. What was working for me was:

 
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
 * @MongoDB\Document
 * @MongoDB\InheritanceType("SINGLE_COLLECTION")
 * @MongoDB\DiscriminatorField(fieldName="type")
 */
class SuperUser
{
    // ...
}


 Comments   
Comment by Jeremy Mikola [ 10/Apr/14 ]

This was actually changed in https://github.com/doctrine/mongodb-odm/commit/ebb7d5fe826f448fc4a53203c23bcc85e610b858. The documentation from that change is what is currently published, but the code is still sitting in the master branch since there's no 1.0.0-BETA10 tag yet.

Your work-around is valid, and will continue to work with 1.0.0-BETA10, since I've left BC support for the old annotation style. My apologies for the inconvenience.





[MODM-175] Removing file data from Document with file removes other fields aswell Created: 26/Aug/13  Updated: 02/Sep/13

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Document Manager
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Peter Jasiulewicz Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Symfony2, Doctrine ODM bundle



 Description   

Not sure if this project isn't abandoned as it looks but here goes.

There is a problem with the gridfs files deletion.
going by description in https://doctrine-mongodb-odm.readthedocs.org/en/latest/reference/storing-files-with-mongogridfs.html?highlight=file

I created a document, the problem is, most of the times, the file is just temporary in mongodb (in my app anyway), and gets deleted after. The deletion (or $document->setFile(null) ) on the @MongoDB\File also removes all other fields in that document, besides the data itself. I have a bunch of statistical information in that document, and it all gets removed when I just remove the file. What's left is just the Id. This might be the way it was intended, however doesn't not really seam like the mapping is accurate here, as it obviously removes a lot more from the database, than I from the object.

The operation should just remove the data that has been removed from the object.



 Comments   
Comment by Jonathan H. Wage [ 02/Sep/13 ]

This project has been a bit more active on github.com/doctrine/mongodb-odm

Comment by Peter Jasiulewicz [ 02/Sep/13 ]

Should I repost it then?

Comment by Jonathan H. Wage [ 02/Sep/13 ]

Yes, I think it would help with other devs/users seeing it.

Comment by Peter Jasiulewicz [ 02/Sep/13 ]

OK, guess this can be closed then as a duplicate. Thanks.

https://github.com/doctrine/mongodb-odm/issues/668





[MODM-172] Fulltextsearch available in Mongo 2.4 is not available in MongoODM Created: 04/Jun/13  Updated: 04/Jun/13

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mongo, MongoCollection, MongoCursor
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Jean-Tristan Chanegue Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Mongo 2.4 / MacosX / PHP 5.3.14



 Description   

Since Mongo 2.4, Fulltextsearch is available: http://docs.mongodb.org/manual/core/text-search/
It's possible to use it directly in PHP :

Command of Mongo 2.4 Text Search feature.

<?php
$result = $db->command(
array(
'text' => 'bar', //this is the name of the collection where we are searching
'search' => 'hotel', //the string to search
'limit' => 5, //the number of results, by default is 1000
'project' => Array( //the fields to retrieve from db
'title' => 1
)
)
);

Sadly it's not available (or i did not find a way..) to use this great feature of Mongo in MongoODM.






[MODM-170] Unique index on embedded document Created: 15/May/13  Updated: 15/May/13

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Szymon Karnecki Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Hi,

Bug checked on versions:
doctrine/mongodb-odm (1.0.0-BETA7)
doctrine/mongodb-odm-bundle (v3.0.0-BETA3)
and
doctrine/mongodb-odm (dev-master 6fd7a46)
doctrine/mongodb-odm-bundle (dev-master 23c08a4)

I've created unique index on embedded document and ODM seem not to be working properly. When unique index is violated MongoCursorException is thrown and this behavior is desired.
But, the document sometimes is persisted anyway. Document structure is invalid.

Thrown exception:
mymongoserver.xx:27017: E11000 duplicate key error index: prj.Grid.$boxes_offer_$id_1_boxes_tag_$id_1 dup key: { : ObjectId('51555bbe31bcb2c70e000001'), : "dom" }

Grid document sketch:

{ _id: boxes:[DBref(Offer), DBref(Offer), DBref(Offer)] tag: DBref(Tag) }

unique index on boxes.tag

Any help would be appreciated.






[MODM-164] DocumentPersister's prepareQuery() method is not suitable for preparing newObj for update queries Created: 05/Apr/12  Updated: 05/Apr/12

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Juha Suni Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Doctrine\ODM\MongoDB\Query\Expr::getNewObj() uses Doctrine\ODM\MongoDB\Persisters\DocumentPersister::prepareQuery() method for preparing newObj. However, prepareQuery is not suitable for that.

The first lines in prepareQuery method should apply to find queries only:


if (is_scalar($query) || $query instanceof \MongoId) {
$query = array('_id' => $query);
}
if ($this->class->hasDiscriminator() && ! isset($query[$this->class->discriminatorField['name']])) {
$discriminatorValues = $this->getClassDiscriminatorValues($this->class);
$query[$this->class->discriminatorField['name']] = array('$in' => $discriminatorValues);
}


Recommendation: DocumentPersister should introduce a new method, such as prepareNewObj($newObj) for preparing the newObj array. Expr::getNewObj() should be change to invoke the new method.






[MODM-162] Introduction Tutorial,suitable version Created: 15/Feb/12  Updated: 15/Feb/12

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Documentation Priority: Major
Reporter: Hugues Leunsa Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

software



 Description   

HI all,

I am working on a project where I would like to use mongoDB ODM. But while following this tutotorial : http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/introduction.html, it appears to me that the download odm library doesn't work with the code: missing code or undefined classes. Therefore I woulld like to know what's the corresponding version mongodb ODM of the tutorial.

Thank's in advance

regards

near






[MODM-161] Bug with index definition Created: 06/Feb/12  Updated: 15/Jun/12

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Erwann Mest Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

MacOS 10.7.2



 Description   

All is there: https://gist.github.com/1682981



 Comments   
Comment by Luis Cordova [ 15/Jun/12 ]

github link has nothing it was removed

Comment by Luis Cordova [ 15/Jun/12 ]

gist is a broken link





[MODM-159] Querying a collection by Embedded objects identifier not working. Created: 30/Nov/11  Updated: 30/Nov/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Dahuda Unal Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

OS:10.8.0 OSX
PHP Official Version 5.3.8
MongoDB : 2.0.1



 Description   

Reference objects identifiers are stored as '$id' in database when Embedded objects identifiers are stored as '_id'. When querying a collection by embedded objects identifier, DocumentPersister->prepareQueryValue() converts it to '$id' although it is stored in DB as '_id'. So querying for reference object ids work but embedded objects do not.

DocumentPersister->prepareQueryValue() first checks if field has TargetDocument mapping, if it is true it checks if field is target document's identifier, if this also returns true
it prepares the field as '$id' without looking at if it is Embedded or Reference object ... If TargetDocument it is a Reference object it works since Reference objects identifiers are stored as '$id' but if TargetDocument is Embedded object, query returns empty as theres no field such '$id' in EmbeddedObject, identifier is '_id' instead..

Is this a bug / issue or am i missing something?






[MODM-158] Doctrine\ODM\MongoDB\Mapping\Type\TimestampType should use MongoDate instead of MongoTimestamp Created: 24/Nov/11  Updated: 24/Nov/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Shane A. Stillwell Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

OS 10.7

PHP 5.3.6 with Suhosin-Patch (cli) (built: Sep 8 2011 19:34:00)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.2, Copyright (c) 2002-2011, by Derick Rethans


Attachments: Text File mongodate.patch    

 Description   

When using the @Timestamp mapping type for a class Doctrine uses MongoTimestamp and it creates very incorrect times in the DB. According to PHP documentation, you should not use MongoTimestamp for creating timestamps, instead MongoDate should be used.

I've attached a patch that changes it to MongoDate and this works splendid when you assign a timestamp to a @Timestamp value

	/**
	 * @Field(type="timestamp")
	 */
	protected $created_on;

	/**
	 * @Field(type="timestamp")
	 */
	protected $updated_on;

	public function __construct($options = NULL)
	{
		$this->created_on = $this->updated_on = time();
		parent::__construct($options);
	}





[MODM-157] Github-PR-151 by l3pp4rd: fixes triggering fatal error on preupdate event in case changeset is clea Created: 25/Aug/11  Updated: 19/Sep/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of

{username}

:

Url: https://github.com/doctrine/mongodb-odm/pull/151

Message:

fixes triggering fatal error on preupdate event in case changeset is cleared during onFlush

similar issue is fixed in ORM it should be supported on ODM mongodb also



 Comments   
Comment by Dmitry Strygin [ 19/Sep/11 ]

Hmm... The bug is still actual for ORM layer in master.

Comment by Vladimir Garvardt [ 19/Sep/11 ]

Got the same issue for ORM in 2.1.1 and same in master. Made a fix based on fix for ODM and pull request on github.

URL: https://github.com/doctrine/doctrine2/pull/126

PS: maybe new issue should be created in Doctrine 2 - ORM project for this issue





[MODM-156] Github-PR-152 by vladar: Property ClassMetadata::file is not serialized Created: 25/Aug/11  Updated: 25/Aug/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of

{username}

:

Url: https://github.com/doctrine/mongodb-odm/pull/152

Message:

This is causing errors, when saving gridfs files with persistent metadata cache engine (like apc, memcached, etc).

I've also found same bug in Jira - http://www.doctrine-project.org/jira/browse/MODM-132 but seems that it is not fixed yet.

Added fix + tests.






[MODM-155] Github-PR-148 by roed: fixed generating of classes Created: 21/Aug/11  Updated: 21/Aug/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of

{username}

:

Url: https://github.com/doctrine/mongodb-odm/pull/148

Message:

fixed the generating of classes based on xml files, changed ClassMetadata to ClassMetadataInfo in these files (as in the ORM tool/mapping)

the following did not work, but works after these changes:
$cmf = new \Doctrine\ODM\MongoDB\Tools\DisconnectedClassMetadataFactory();
$cmf->setDocumentManager($this->_dm);
$cmf->setConfiguration($this->_dm->getConfiguration());
$driver = $this->_dm->getConfiguration()->getMetadataDriverImpl();

$metadatas = $cmf->getAllMetadata(); //this would break it

// $this->_dm is an instance of Doctrine\ODM\MongoDB\DocumentManager






[MODM-154] Github-PR-150 by tecbot: [XMLDriver] fixed an error in hydration classes when the name is not equal to the fieldName Created: 21/Aug/11  Updated: 21/Aug/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of

{username}

:

Url: https://github.com/doctrine/mongodb-odm/pull/150

Message:






[MODM-152] Single Collection Inheritance mapping does NOT work if the subclasses are in a different namespace Created: 09/Jul/11  Updated: 09/Jul/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Dayson Pais Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I have described the issue in detail here: https://github.com/doctrine/mongodb-odm/issues/124






[MODM-151] Missing Annotation class HasLifecycleCallbacks Created: 07/Jul/11  Updated: 07/Jul/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Miloslav "adrive" Kmet Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

latest MongoDB ODM from git master repository



 Description   

Annotation class HasLifecycleCallbacks is missing in Doctrine\ODM\MongoDB\Mapping\Annotations






[MODM-150] XSD file for XML mappings is incomplete Created: 07/Jul/11  Updated: 07/Jul/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: alcaeus Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None

Attachments: Text File doctrine-mongo-mapping.xsd.patch    

 Description   

The XSD file for XML mappings (http://www.doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd) appears to be incomplete:

  • Only document is allowed as root tag, not mapped-superclass or embedded-document
  • The name attribute for the document tag is not allowed according to the XSD file
  • The fieldName, index and unique attributes for the field tag is not allowed according to the XSD file

These are the problems I discovered at the moment, I haven't yet checked for more problems. The XSD file probably needs a bigger update.

Attached is a patch file that adds the missing attributes, I haven't dug into Doctrine enough to create the mapped-superclass or embedded-document tags.






[MODM-148] Do not add '$db' in reference when referencing document from same $db Created: 02/Jun/11  Updated: 02/Jun/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Document Manager
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Vladimir Razuvaev Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When using ReferenceOne or ReferenceMany , doctrine will create fully-qualified reference to the object (with all fields: '$id', '$ref', '$db') even when reference is within same $db.

This approach causes several problems: for example we use mongo database as a template for new clients - when new client registers, template database is copied for him. But since it contains hardcoded $db - copy operation becomes resource consuming, since we have to loop through every document of every collection and fix $db reference.

Also maintenance suffers, since you can't easily rename database when required.

Is it possible to omit $db part when referencing document from same db?






[MODM-142] DocumentRepository::findBy() not compatible with interface Created: 07/May/11  Updated: 07/May/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Document Repositories
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Jan Pieper Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I want to get a document repository for my Document\Event document class but instead i get a fatal error.

Pseudo
<?php

use Doctrine\MongoDB\Connection;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Configuration;
use Documents\Event;

$manager = new DocumentManager(
    new Connection(...),
    new Configuration(...)
);

$manager->getRepository('Documents\Event');

Fatal error: Declaration of Doctrine\ODM\MongoDB\DocumentRepository::findBy() must be compatible with that of Doctrine\Common\Persistence\ObjectRepository::findBy() in /home/jpieper/Workspace/Jersey/vendor/doctrine-common/lib/Doctrine/ODM/MongoDB/DocumentRepository.php on line 39

DoctrineCommonPersistenceObjectRepository.php (github@5a285537)
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null);
DoctrineODMMongoDBDocumentRepository.php (github@8d02e843)
public function findBy(array $criteria) { ... }

See https://github.com/doctrine/common/commit/5a2855372834cf37e0408e80dcb9a9c97ec1d352#lib/Doctrine/Common/Persistence






[MODM-141] Doctrine ODM: Documentation error Created: 26/Apr/11  Updated: 26/Apr/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Documentation Priority: Major
Reporter: Diego Lewin Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

not applicable



 Description   

I think that is a documentation issue, in http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/query-builder-api.html (15.3. Modifier Operations) the queries are like:

$dm->createQueryBuilder('User')

>field('password')>set('newpassword')

>field('username')>equals('jwage')

->getQuery()
->execute();

But it is missing the update(), it should be like:

$dm->createQueryBuilder('User')

->update()
>field('password')>set('newpassword')

>field('username')>equals('jwage')

->getQuery()
->execute();

All the queries in that section have similar issue






[MODM-140] Issue with nested embdedded documents after adding an EmbeddedDocument to Document Created: 14/Apr/11  Updated: 19/Dec/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: UnitOfWork
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Andrew Cobby Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 5
Labels: None
Environment:

PHP 5.3.3, Mac OS X 10.6.6, MongoDB 1.8.0


Attachments: File doctrine-odm-patch-1.0.0beta3.diff     File MODM140Test.php    

 Description   

I'm using the latest version of Doctrine ODM (fresh from Git).

I have three levels of Documents (Two embedded); Category -> EmbedsMany: Post -> EmbedsMany PostVersion.

Step-by-step:

1. Make a new Post (Post1), 2 PostVersions (PostVersion1 and 2) and a Category
2. Add Post1 to Category
3. Persist Category, Flush, Clear
4. Retrieve Category
5. Make a new Post (Post2) and 2 PostVersions(PostVersion3 and 4)
6. Add Post2 to Category
7. Flush

If you're following properly, at this stage in the database there should be:
1 Category,
2 Posts
4 PostVersions ... 2 PostVersions in each Post

However, what actually happens is:
1 Category,
2 Posts
4 PostVersions ... 4 PostVersions in Post1, 0 PostVersions in Post2

On StackOverflow: http://bit.ly/ekFbe2
Testcase Gist: https://gist.github.com/920914

A work around is to make Post2 and add it to Category, flush, then make new PostVersions and flush again.

I did some debugging but I don't know enough about the internals to fix the issue.



 Comments   
Comment by Andrew Cobby [ 14/Apr/11 ]

Failing test

Comment by Andrew Cobby [ 14/Apr/11 ]

Added a test using the EmbdeddedTestLevelX Documents, please refer to Gist: https://gist.github.com/920914

For some reason, they work? I'm thinking maybe this isn't a bug... very confused at the moment.

Comment by Andras Revai [ 18/Jun/11 ]

I've got the same problem.

Comment by Kelvin Wood [ 09/Aug/11 ]

I had a similar problem, and resolved it with the attached patch (based on the 1.0.0beta3 release).

This patch causes the ODM to stop scanning for changes further down the heirachy once it finds a new object, and then ensures that the Persistence Builder will include all contents of the new item.

Comment by Richard Shank [ 19/Dec/11 ]

Kevin, do you want to put a PR in on github for this?





[MODM-139] [PATCH] @ReferenceMany with no referenceMapping cannot handle DBRef in all / in queries Created: 08/Apr/11  Updated: 08/Apr/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Document Manager
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Gérald Croes Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Linux, PHP 5.3



 Description   

I have thoose examples :

/** @Document 
 * @InheritanceType("SINGLE_COLLECTION")
 * @DiscriminatorField(fieldName="type")
 * @DiscriminatorMap({"Test\Product"="Product", "Test\Year"="Year"})
*/
Attributes {
   /** @Id */
   protected $_id;
}

/** @Document */
class Product extends Attributes {}

/** @Document */
class Year extends Attributes {}

/**
 * Classe de base pour les différents contenus
 * @Document
 * @InheritanceType("SINGLE_COLLECTION")
 * @DiscriminatorField(fieldName="type")
 * @DiscriminatorMap({"Test\Document"="Document", "Test\Infos"="Infos"})  
 */
class Content
{
   /** protected $_id */
    /** @ReferenceMany */
    protected $_attributes;
}

And the querying stuff

//and the query : 
$queryBuilder = $dm->createQueryBuilder('Test\DOcument');
//...
$attribute1Ref = $dm->createDBRef($attribute1Object);
$attribute2Ref = $dm->createDBRef($attribute2Object);
$queryBuilder->field('_attributes')->all(array($attribute1Ref, $attribute2Ref));
$queryBuilder->getQuery()->execute();//Won't work as the generated query won't specify the "_doctrine_class_name" value.

Proposed patch in DocumentManager :

    /**
     * Returns a DBRef array for the supplied document.
     *
     * @param mixed $document A document object
     * @param array $referenceMapping Mapping for the field the references the document
     *
     * @return array A DBRef array
     */
    public function createDBRef($document, array $referenceMapping = null)
    {
        $className = get_class($document);
        $class = $this->getClassMetadata($className);
        $id = $this->unitOfWork->getDocumentIdentifier($document);

        $dbRef = array(
            $this->cmd . 'ref' => $class->getCollection(),
            $this->cmd . 'id'  => $class->getDatabaseIdentifierValue($id),
            $this->cmd . 'db'  => $this->getDocumentDatabase($className)->getName()
        );

        // add a discriminator value if the referenced document is not mapped explicitely to a targetDocument
        if ($referenceMapping && ! isset($referenceMapping['targetDocument'])) {
            $discriminatorField = isset($referenceMapping['discriminatorField']) ? $referenceMapping['discriminatorField'] : '_doctrine_class_name';
            $discriminatorValue = isset($referenceMapping['discriminatorMap']) ? array_search($class->getName(), $referenceMapping['discriminatorMap']) : $class->getName();
            $dbRef[$discriminatorField] = $discriminatorValue;
+        }  elseif ($referenceMapping === null) {
+            $dbRef['_doctrine_class_name'] = $class->getName();
+        }
        return $dbRef;
    }





[MODM-138] Field's name attribute does not work for the update queries Created: 07/Apr/11  Updated: 07/Apr/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Başar Aykut Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Documents

class Test 
{
.
.
.
/**
 * @EmbedOne(targetDocument="Location", name="l")
*/
private $location;
.
.
.
}

/** @EmbeddedDocument */
class Location
{
    /**
	 * @Field(type="float", name="y")
	 */
    public $lat;

    /**
	 * @Field(type="float", name="x")
	 */
    public $lng;

	public function __construct($latitude,$longitude) {
		$this->lat = $latitude;
		$this->lng = $longitude;
	}
}

Update query:

$dm->createQueryBuilder('Test')
->update()
->field('id')->equals(123)
->field('l')->set(new Location(39, 32);
->getQuery(array('upsert' => true))
->execute();

Result of this query is

"l": {
    "lat": 39,
    "lng": 32
},

however, it should be

"l": {
    "y": 39,
    "x": 32
},

also field function can support field name of the class on update queries, as follows

$dm->createQueryBuilder('Test')
->update()
->field('id')->equals(123)
->field('location')->set(new Location(39, 32);
->getQuery(array('upsert' => true))
->execute();





[MODM-137] Undefined index 'criteria' in DocumentPersister Created: 04/Apr/11  Updated: 04/Apr/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Persister
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Kevin Bradwick Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

On the master branch, a notice is thrown on line 531 of the DocumentPersister for an undefined index 'criteria'. This is when using the Yaml driver.

https://github.com/doctrine/mongodb-odm/blob/master/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php#L531

Full notice:
Notice: Undefined index: criteria in /Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php on line 531
PHP Warning: array_merge(): Argument #2 is not an array in /Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php on line 532

Warning: array_merge(): Argument #2 is not an array in /Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php on line 532
PHP Catchable fatal error: Argument 1 passed to Doctrine\MongoDB\Collection::find() must be an array, null given, called in Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php on line 533 and defined in Doctrine/MongoDB/Collection.php on line 169

Catchable fatal error: Argument 1 passed to Doctrine\MongoDB\Collection::find() must be an array, null given, called in Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php on line 533 and defined in /Doctrine/MongoDB/Collection.php on line 169






[MODM-136] Document's fields names are not properly converted to database names in a query Created: 27/Mar/11  Updated: 27/Mar/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Eugene Leonovich Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None


 Description   

Mappings:

/**
 * @Field(type="date", name="scheduled_at")
 */
private $scheduledAt;

/**
 * @Field(type="date", name="completed_at")
 */
private $completedAt;

Query:

$qb->field('scheduledAt')->lte($now)
   ->addOr($qb->expr()->field('completedAt')->lte($now))
   ->addOr($qb->expr()->field('completedAt')->equals(null))
   ->sort('scheduledAt', 'asc');

Expected result:

db.foo.find({
    "scheduled_at": { "$lte": new Date(...) }, 
    "$or": [ 
        { "completed_at": {  "$lte": new Date(...) } }, 
        { "completed_at": null } ] 
})
.sort({ "scheduled_at": 1 });

Actual result:

db.foo.find({
    "scheduled_at": { "$lte": new Date(...) }, 
    "$or": [ 
        { "completedAt": {  "$lte": new Date(...) } }, 
        { "completedAt": null } ] 
})
.sort({ "scheduledAt": 1 });





[MODM-135] [Cursor] ReferenceMany sort mapping not working Created: 25/Mar/11  Updated: 26/Mar/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: jules b Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Macosx


Attachments: Zip Archive MODM135.zip    

 Description   

I have a document like this:

/** @Document */
class Page
{
/** @Id */
protected $id;

/** @ReferenceMany(sort=

{"order"="asc"}

) */
protected $blocks;
}

If i have well understood things, i can do:

$blocks = $dm->getRepository('Page')>find($id)>getBlocks();

blocks should now be sorted by $order property.

This behaviour doesn't seems to work (or maybe i'm missing something).
In the attachment there's a test case

i made the priority major because in my case i haven't found a workaround (i'm using nested referenceMany, a child can have children, which can have children, ..).






[MODM-134] Reference added twice Created: 24/Mar/11  Updated: 25/Mar/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: jules b Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I have a listener who listens on onFlush event,
i have a document and change a property (integer) in it and call $uow->recomputeSingleDocumentChangeSet().
The result is that all references are added twice.

If i remove the call to $uow->recomputeSingleDocumentChangeSet() all is fine.

Here's my document (notice references added twice on children property):

array (
'children' =>
array (
0 =>
array (
'$ref' => 'block',
'$id' => new MongoId("4d8b663638b6180803000005"),
'$db' => 'app_jules',
'_doctrine_class_name' => 'Design\\PageBundle\\Document
StrategyBlock',
),
1 =>
array (
'$ref' => 'block',
'$id' => new MongoId("4d8b663638b6180803000005"),
'$db' => 'app_jules',
'_doctrine_class_name' => 'Design\\PageBundle\\Document
StrategyBlock',
)
),
'order' => 0,
'parent' =>
array (
'$ref' => 'block',
'$id' => new MongoId("4d8b663638b6180803000003"),
'$db' => 'app_jules',
'_doctrine_class_name' => 'Design\\PageBundle\\Document
ContainerBlock',
),
'type' => 'container',
)

EDIT: if i clear() the $children ArrayCollection before calling $uow->recomputeSingleDocumentChangeSet() all is fine

I tried to reproduce it in a test-case but the result wasn't successful






[MODM-132] Doctrine\ODM\MongoDB\Mapping\ClassMetaData is loosing "file" property after serialization Created: 18/Mar/11  Updated: 18/Mar/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Andrei S Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

After ClassMetaData is awakened it looses the "file" property and that breaks our File model.
File::count() returns 0

I dumped ClassMetaData object with caching enabled and disabled. Here's the diff:

146c146
< [file] =>

> [file] => file
149a150,180
> [0] => Array
> (
> [keys] => Array
> (
> [uploaded_at] => 1
> )
>
> [options] => Array
> (
> [safe] => true
> [unique] =>
> )
>
> )
>

The first line is the missing file value. The second block appears to be missing indexes but I'm guessing this information should not be serialized.






[MODM-131] Notice in Doctrine\MongoDB\GridFS::doInsert Created: 09/Mar/11  Updated: 09/Mar/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Vitaliy Kaplich Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

CentOS 5.5, PHP 5.3



 Description   

Notice: Undefined variable: file in /projects/tbi/vendors/doctrine/odm/lib/vendor/doctrine-mongodb/lib/Doctrine/MongoDB/GridFS.php on line 112






[MODM-129] Storing embeded documents containing embeded documents, already persistet in another collection fails Created: 25/Feb/11  Updated: 25/Feb/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Kolja Treutlein Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None

Attachments: GZip Archive testcase.tar.gz    

 Description   

We persist a document a1 containing an embedded document a1.1 which itself contains another embedded document a1.1.1. When the embedded document a1.1 is moved to another document of another collection b1 and needs to get persisted as embedded document b1.1 the embedded document a1.1.1 (which is now part of b1.1, too) is not saved as an embedded document of b1.1.

Example: We use a version object which contains a pageversion as an embedded document. This page object contains multiple elements (stored as embedded documents) which themselves contain several parameter objects (stored as embedded document of elements). Now assume we have such a persisted version and want to "copy" the pageversion in another collection. So we generate a new page object, and add to this page all elements of the persisted pageversion. If we now persist this page, the representation in mongodb contains all elements but not any parameters, which should be part of the page as well (as they are part of an element).



 Comments   
Comment by Kolja Treutlein [ 25/Feb/11 ]

Testcase

Comment by Jonathan H. Wage [ 25/Feb/11 ]

Try cloning the embedded document when you move it. The reason why you have issues most likely is because internally inside Doctrine we keep track of each embedded document instance and what parent document it is attached to. So when you move it, Doctrine gets confused. You need to move it by cloning so the embedded document is actually a new object instance to Doctrine.





[MODM-128] Upserts in Query builder Created: 23/Feb/11  Updated: 23/Feb/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA2
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Billy Bob Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Mac OS X + MAMP



 Description   

It seems that if you just call upsert(true) in a update request, it won't be enough. You have to calm getQuery(array('upsert' => true)) as well in order to have the 'insert if not exist' working.






[MODM-82] Add New Attribute "idGetter" to allow accessing the ID without triggering lazy-load Created: 29/Sep/10  Updated: 04/Mar/11

Status: Open
Project: Doctrine MongoDB ODM
Component/s: Proxies
Affects Version/s: 1.0.0BETA2
Fix Version/s: 1.1.0

Type: New Feature Priority: Major
Reporter: Thomas Adam Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

access the ID of a proxy without loading it.

See DDC-687






Generated at Tue Oct 21 17:09:30 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.