[MODM-116] Collection Per Class Inheritance : Documents of a child class referenced in a parent class may be saved to the parent collection Created: 07/Feb/11  Updated: 21/Apr/11

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

Type: Bug Priority: Critical
Reporter: JF Bustarret Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Here is my class hierarchy (classes & attributes renamed for a better understanding) :

 
/** @Document @InheritanceType("COLLECTION_PER_CLASS") **/
class Parent {
    /** @ReferenceOne(targetDocument="Child") **/
    protected $child;
}

/** @Document **/
class Child extends Parent {
}

When doing :

$parent->setXXX($value);
$parent->getChild()->setXXX($value2)

the $parent->getChild() document is saved to the Parent collection.

It looks like the problems lies in UnitOfWork::executeUpdates :

 
if (get_class($document) == $className || $document instanceof Proxy && $document instanceof $className) {

$child_document is an instance of Proxy (ChildProxy) and also an instance of Parent => saved using the Parent persister.

Shouldn't the test be : get_class($document) == $className || get_class($document) == $className_of_Proxy ?

As a side note : why "if ($class->isEmbeddedDocument)

{ continue; }

" is within the foreach and not a "if ($class->isEmbeddedDocument)

{ return; }

" at the beginning of the method ?



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

I added a test for this here and it appears to be passing: https://github.com/doctrine/mongodb-odm/commit/3f24d77cc04adc0bb5532333e33826100457c666

Comment by JF Bustarret [ 11/Feb/11 ]

I'll try to get more info on the problem and provide a test for it.

Comment by JF Bustarret [ 28/Mar/11 ]

Here is a new test case :

 
/** @Document
 *  @InheritanceType("COLLECTION_PER_CLASS")
 **/
class MODM116Parent
{
    /** @Id */
    private $id;

    /** @String */
    private $name;

    /** @ReferenceOne **/
    private $child;

    public function getId()
    {
        return $this->id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getChild()
    {
        return $this->child;
    }

    public function setChild(MODM116Child $child)
    {
        $this->child = $child;
    }
}

/** @Document **/
class MODM116Child extends MODM116Parent
{
    
    /** @EmbedMany(targetDocument="MODM116Embedded") **/
    protected $embedded;
    
    function addEmbedded($parent) {
        $this->embedded[] = new MODM116Embedded($parent);
    }
}

/** @EmbeddedDocument **/
class MODM116Embedded {
    
    /** @ReferenceOne(targetDocument="MODM116Parent") **/
    protected $parent;
    
    public function __construct($parent) {
        $this->parent = $parent;
    }
    
}


$parent = new MODM116Parent();
$parent->setName('test');
$parent->setChild(new MODM116Child());
$dm->persist($parent->getChild());
$dm->persist($parent);
$dm->flush();
$dm->clear();

$parent = $dm->getRepository(get_class($parent))->findOneBy(array('name' => 'test'));

$parent->getChild()->setName('ok');
$parent->getChild()->addEmbedded($parent);
$dm->flush();
Comment by JF Bustarret [ 30/Mar/11 ]

Pulled the last version from git. The bug still exists.

Comment by JF Bustarret [ 21/Apr/11 ]

Up. Any news on a fix ?





[MODM-149] Fix PHPDoc @return types in various places Created: 05/Jul/11  Updated: 05/Apr/12

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

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


 Description   

In certain PHPDoc blocks for functions, the @return type is not of the right type. This causes auto-completion issues in various IDEs (I'm using PhpStorm).

For example, in \Doctrine\ODM\MongoDB\DocumentManager on line #341 the ->createQueryBuilder($documentName = null) function.

/**

  • Create a new Query instance for a class.
    *
  • @param string $documentName The document class name.
  • @return Document\ODM\MongoDB\Query <--------------------------- MUST BE Query\Builder !
    */
    public function createQueryBuilder($documentName = null) { return new Query\Builder($this, $this->cmd, $documentName); }


 Comments   
Comment by Lee Davis [ 05/Apr/12 ]

This appears to be fixed in 1.0.0BETA4-DEV

Line 357 in Doctrine\ODM\MongoDB\DocumentManager...

/**

  • Create a new Query instance for a class.
    *
  • @param string $documentName The document class name.
  • @return Query\Builder
    */
    public function createQueryBuilder($documentName = null) { return new Query\Builder($this, $this->cmd, $documentName); }




[MODM-153] "Near" Query does not work. Created: 10/Aug/11  Updated: 20/Feb/12

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

Type: Bug Priority: Critical
Reporter: Dmitry Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

"Near" statement does not work for me. The following code returns all cities from collection:

$cities = $this->dm->createQuery('City')
    ->field('coordinates')->near(50, 60)
    ->execute();

Could you please fix it?



 Comments   
Comment by mark wright [ 02/Sep/11 ]

It also does not work in beta3 but it fails differently. It never returns anything.

$places = $documentManager->createQueryBuilder('Documents\Place')
->field('point')
->near(36.5788494, -121.7207804)
->getQuery()
->execute();

This returns 0 documents even though I have a point at 36.5788493, -121.7207805. Doctrine\MongoDB\Query\Builder::near() only takes one argument so the Y value is ignored. However, the docblock specifies 2 params.

Comment by Tim Sakharchuk [ 04/Sep/11 ]

Hi All,

Here is correct realization of this function in
Doctrine\MongoDB\Query\Builder

public function near($x, $y)

{ $this->query['type'] = Query::TYPE_GEO_LOCATION; $this->query['near'] = array($x, $y); return $this; }

When may this fix appear in Doctrine ODM?

Thanks!

Comment by Shane A. Stillwell [ 20/Feb/12 ]

I had the same issue on 1.0.0.BETA3.

The solution was to change the query up a little.

$places = $this->dm->createQueryBuilder('\Application\Event')->field('latitude')->near(50)->field('longitude')->near(60)->getQuery()->execute(); 

http://stackoverflow.com/a/9015906/179335





[MODM-179] Wrong LifecycleCallbacks type object passed Created: 16/Jan/14  Updated: 16/Jan/14

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

Type: Bug Priority: Critical
Reporter: Pierre B Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

PHP 5.4.24
Symfony 2.4



 Description   

I've an exception error when trying to update an object, due to the lifecycle callback:

Expected document class "Ae\CoreBundle\Document\Advertiser"; found: "MongoDBODMProxies_CG_\Ae\CoreBundle\Document\Advertiser"

The stack trace says it comes from:
ClassMetadataInfo ->invokeLifecycleCallbacks ('preUpdate', object(Advertiser))

I have to disable my lifecycle callbacks to keep my app working... wich is really bad.

Thank you for your help,

Best regards






[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






[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-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-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-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-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-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-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-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-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-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-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-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-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-147] No possibility to get a json object by a working document with toArray method (inluding all the embedded documents as arrays) Created: 28/May/11  Updated: 28/May/11

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

Type: New Feature Priority: Major
Reporter: Stephan Salat Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Irrelevant



 Description   

Description of the problem here:

http://stackoverflow.com/questions/6155189/doctrine-odm-mongodb-get-a-complete-array-of-an-object

Problem with the unincisive toArray() method.






[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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-126] lessThanOrEq() renamed in lte() Created: 22/Feb/11  Updated: 22/Feb/11

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

Type: Documentation Priority: Minor
Reporter: Billy Bob Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The lessThanOrEq() function referenced in the documentation does not exist ay more, it was replaced by lte().

http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/query-builder-api.html






[MODM-127] Update queries : update() required ? 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: Documentation Priority: Minor
Reporter: Billy Bob Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

In the documentation exemples for update queries :
http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/query-builder-api.html#update-queries

it doesn't mention a update() function call any more in update queries.

Did I miss something?






[MODM-130] @ChangeTrackingPolicy notation is ignored in @MappedSuperclass Created: 02/Mar/11  Updated: 02/Mar/11

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

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

CentOS 5.5, PHP 5.3



 Description   

I am not sure if it's supposed to be that @MappedSuperclass document can define @ChangeTrackingPolicy for multiple documents but in fact it does not work.

In other words in the case below:
===================================================

/**

  • @MappedSuperclass
  • @InheritanceType("COLLECTION_PER_CLASS")
  • @ChangeTrackingPolicy("DEFERRED_EXPLICIT")
    */
    abstract class MappedDocument
    {
    }

/**

  • @Document(collection="chart")
    */
    class Chart extends MappedDocument
    {
    }

===================================================

class Chart

  • has InheritanceType = INHERITANCE_TYPE_COLLECTION_PER_CLASS which is expected
  • but ChangeTrackingPolicy = CHANGETRACKING_DEFERRED_IMPLICIT (value by default) which is NOT expected.

At the same time if to define ChangeTrackingPolicy in the Chart class instead of MappedDocument it works as expected.






[MODM-144] Bi-Directional References Feature Created: 18/May/11  Updated: 18/May/11

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

Type: Bug Priority: Minor
Reporter: Jan Gantzert Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Zend Framework 1.11.6



 Description   

I cant´t reproduce the Bi-Directional References with my own example or the example of the documentation.
Perhaps the documentation is not up to date or their ist a bug.

BlogPost.php
<?php

/** @Document */
class BlogPost
{
/** @Id */
public $id;

/** @String */
public $title;

/** @String */
public $content;

/** @String */
public $createtime;

/** @String */
public $updatetime;

/** @ReferenceMany(targetDocument="PostComment", mappedBy="post") */
private $comments;
}

PostComment.php
<?php

/** @Document */
class PostComment
{
/** @Id */
public $id;

/** @String */
public $name;

/** @String */
public $mail;

/** @String */
public $content;

/** @String */
public $createtime;

/** @String */
public $updatetime;

/** @ReferenceOne(targetDocument="BlogPost", inversedBy="comments") */
private $post;
}

CommentController.php
// Save the Post
$post = new BlogPost();
$post->setTitle = 'testtitle';
//$post->content = 'testcontent';
//$post->createdate = time();

$comment1 = new PostComment();
$comment1->title = 'testcommenttitle1';

$comment2 = new PostComment();
$comment2->title = 'testcommenttitle2';

$comment3 = new PostComment();
$comment3->title = 'testcommenttitle3';

$dm->persist($comment1);
$dm->persist($comment2);
$dm->persist($comment3);
$dm->flush();

echo $post->id;

/*$posts = $dm->createQueryBuilder('BlogPost')
->getQuery();*/

$post = $dm->getRepository('BlogPost')->find('4dd45739f563724c23000002');

Zend_Debug::dump($post);
$comments = $post->getComments();

------------------------
In the documentation the example is
$post1->setUser($user);
But the only working for me is:
$post->setTitle = 'testtitle';

Anyway, I can´t get the Comments from the mongodb.
I always get this error.
Fatal error: Call to undefined method BlogPost::getComments()
This is a correct error message because BlogPost really dont have a getComments()
method. How do I get my Comments then?
Any help would be great.

Greetings tronga






[MODM-145] QueryBuilder references() to does not support references on embedded objects' fields Created: 23/May/11  Updated: 25/Oct/11

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

Type: New Feature Priority: Minor
Reporter: Jeremy Mikola Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I noticed that the references() method does not support fields on embedded objects, as the argument to the preceding field() method will be passed into getFieldMapping() and trigger an exception. I suppose a solution would require multiple calls to getFieldMapping() in order to dive into the embedded object's class metadata.

To demonstrate, below is an example of a UserRepository class. The User document contains an embeddedObject that itself references another User:

class UserRepository extends DocumentRepository
{ 
    public function findByEmbeddedObjectReference(User $user)
    {
        return $this->createQueryBuilder()
            ->field('embeddedObject.user.$id')->equals($user->getId())
//          ->field('embeddedObject.user')->references($user)
            ->getQuery()
            ->execute();
    }
}

Using field()/equals() works fine as an alternative to references(), so there is no urgent need for this feature.



 Comments   
Comment by Nicolas Brignol [ 25/Oct/11 ]

Hi

It seems that we have a problem with the temporary solution proposed :
Doctrine remove the "$id" part in our query :

   obj->field('embedded.referenced.$id')->equals($reference->getId())

will generate the query without "$id".
There is no problem when the reference is directly in the requested object.

Did someone experience this issue ?





[MODM-163] @ReferenceMany and Inheritance Created: 01/Mar/12  Updated: 01/Mar/12

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

Type: Bug Priority: Minor
Reporter: julie sommerville Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None
Environment:

php 5.3 macosx 10.7.3 mongodb-odm 1.0 mongodb v2.0.2



 Description   

@ReferenceMany doesn't seem to work when used within a child class unless I specify @InheritanceType("CLASS_PER_COLLECTION") (which is fine b/c that works for our architecture)

Here is an example from our code:

//Parent Class

use Doctrine\Common\Collections\ArrayCollection;

/**

  • @Document(collection="homepages")
  • @ChangeTrackingPolicy("DEFERRED_IMPLICIT")
  • @Indexes({
  • @Index(keys= {"vertical"="asc","ts"="desc"}

    , safe="true"),

  • @Index(keys= {"ts"="desc"}

    , safe="true")

  • })
    */
    class Homepage extends MappedDocument
    {

//** References
/**

  • @ReferenceMany(targetDocument="Post")
  • @var list<Post>
    */
    protected $touts;

}

//Child Class
/**

  • @Document(collection="readmes")
  • @ChangeTrackingPolicy("DEFERRED_IMPLICIT")
  • @Indexes({
  • @Index(keys= {"vertical"="asc"}

    , safe="true")

  • })
    */
    class Readme extends Homepage { //** References /** * @ReferenceMany(targetDocument="Post") * @var list<Post> */ protected $more_touts; }

If I don't add the @InheritanceType annotation the $more_touts data never gets persisted into the DB.
Other types such as @ReferenceOne all work just fine






[MODM-168] Can't Use Custom Repository Class for Embedded Doc When Using YAML Driver Created: 29/Jul/12  Updated: 29/Jul/12

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

Type: Bug Priority: Minor
Reporter: Isaac Foster Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When using the Yaml driver the ClassMetadata generation process won't create and use the indicated custom repository class for an embedded document. From what I can see digging into the actual code, it will work when using the Annotations or XML drivers, but in the Yaml driver the call to setCustomRepositoryClass is inside of a conditional that only gets entered if the document type is 'document'.

I'm not completely sure, but from what I can see elsewhere in the code, it looks like mapped superclasses should also be able to have a custom repository class, but can't when using the Yaml driver.

So I reckon what would work would be to change the code as indicated below:

<<EXISTING CODE>>
//Doctrine/ODM/MongoDb/Mapping/Driver/YamlDriver.php, line 66
if ($element['type'] == 'document') {
if (isset($element['repositoryClass']))

{ $class->setCustomRepositoryClass($element['repositoryClass']); }

} elseif ($element['type'] === 'mappedSuperclass')

{ $class->isMappedSuperclass = true; }

elseif ($element['type'] === 'embeddedDocument')

{ $class->isEmbeddedDocument = true; }

<<TO THIS>>
if (isset($documentAnnot->repositoryClass))

{ $class->setCustomRepositoryClass($element['repositoryClass']); }




[MODM-169] Filter API is not unified between ODM and ORM Created: 10/Dec/12  Updated: 10/Dec/12

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

Type: Improvement Priority: Minor
Reporter: Craig Marvelley Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None


 Description   

Hi,

I'm implementing some functionality around filters which will ideally work for both ORM and ODM. The API for managing filters is different on `Doctrine\ORM\EntityManager` and `Doctrine\ODM\MongoDB\DocumentManager`, while the CouchDB implementation of ODM has no filter concept.

For example, ORM EntityManager has getFilters(), hasFilters(), while ODM MongoDB DocumentManager has getFilterCollection().

I was wondering what your thoughts were on defining the filter API in an interface, to improve consistency when implementing cross-library functionality?

Thanks,
Craig






[MODM-173] Change the name of the collection dynamic Created: 27/Jun/13  Updated: 27/Jun/13

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

Type: Improvement Priority: Minor
Reporter: Daniel Gafitescu Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I have to create collection for users per each day they register so if I have 5 users and 2 register on 2013-03-02 and 3 have register on 2013-03-03 I will have 2 collections

The user is declare in a YML file with no collection specified

In the project I do an import via CLI something like this

foreach($arUsers as $key => $arUser)
{

    $collection_name = 'day_' . $arUser['date'];


    $user = new User();

    /* Change the collection name to be dynamic  */
    $OdmMetaData = $documentManager->getClassMetaData(get_class($user));

    $OdmMetaData->setCollection($collection_name);

    $user->setUserId($arUser['user_id']);
    $user->setEmail($arUser['email']);

    // ....

    $this->getDocumentManager()->persist($user);
    $this->getDocumentManager()->flush();
    
    // should save the user to `'day_' . $arUser['date']`
}

Problem is that when I look in the mongoDB I see only one collection with name "day_2013-03-03" which is the last date , if I set the

$documentManager->flush();

after the foreach end statement which I should it save all in the first collection "03-02".



 Comments   
Comment by Marco Pivetta [ 27/Jun/13 ]

I personally don't think that's an use case to be handled in the ODM.

The problem is that class metadata properties are not constantly accessed, but instead cached locally in various components for performance reasons.

A fix for this would be to explicitly deny modification of metadata after it was returned by the metadata factory (after "onLoadMetadata" events).

Comment by Daniel Gafitescu [ 27/Jun/13 ]

Reinitialize the DoctrineManager at every group of document did the trick but it's just not beautiful code.
In a perfect world it would be nice to have a method setCollectionName on a object. But then again Doctrine is a open source project and all that work on the project are doing this on their own time and I thank you for that.





[MODM-176] includesReferenceTo query failure Created: 09/Nov/13  Updated: 20/Jan/14

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

Type: Bug Priority: Minor
Reporter: Hussain Nazan Naeem Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: dql
Environment:

MongoDB shell version: 2.4.6



 Description   

Problem explained below as an example.
Suppose Car model has referenceMany relation with Wheel model.

/** @ReferenceMany(targetDocument="Wheel", inversedBy="car", simple=true) */
protected $wheels

note the simple=true param. If this param is specified then includesReferenceTo queries fail for Car model.

For example, following query fails:

$cars = $dm->createQueryBuilder('Car')
            ->field('wheels')
            ->includesReferenceTo($wheel)
            ->getQuery()
            ->execute();





[MODM-177] mapping import with multiple schema Created: 02/Dec/13  Updated: 02/Dec/13

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

Type: Bug Priority: Minor
Reporter: Alexandre PIEL Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I am importing the structure of my database by using doctrine:mapping:import
When I run doctrine:generate:entities I get the error: Invalid mapping file

The exception come from the following code in the function getElement l.105 if the class Doctrine\Common\Persistence\Mapping\Driver\FileDriver

if (!isset($result[$className]))

{ throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->locator->getFileExtension()); }

When I look more in details we have

$clasName = "Company\Eg\Entity\Schema\table"

And $result is:

array(1) {
["Company\Eg\Entity\Schema.table"]=>
array(5) {
(...)

I am using PostgreSQL with multiple schemas for a single database.






[MODM-178] Add an event that allows adjustment of a query prior to being executed Created: 03/Jan/14  Updated: 03/Jan/14

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

Type: New Feature Priority: Minor
Reporter: Westin Pigott Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I would like to add an event which is triggered upon the creation of a query, and prior to the query being executed. This would allow the query to be modified prior to execution.

This would be useful in the following use case (off the top of my head):

  1. A developer needs to set the scope of a query. An example would be: In a white-label site situation where you want to make sure the login only checks for the correct user in the scope of the domain. Rather than needing to make sure that every query has the scope added when the query is defined, the scope could be added prior to execution.
  2. Users want to enable encryption on certain fields. The encrypting and decrypting part are fairly straight-forward using the existing events. The problem is encountered when you have to be aware of the encryption when composing a query. If we could modify the query prior to execution, we could check the fields and adjust the search values as needed.


 Comments   
Comment by Westin Pigott [ 03/Jan/14 ]

BTW, if you point me in the general direction, I would be happy to do the work on this issue.





Generated at Fri Aug 01 10:01:50 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.