[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.





[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-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-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-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-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-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-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-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-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-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-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






Generated at Thu Jul 31 13:35:32 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.