[MODM-93] YAML and XML mapping drivers ignore discriminatorField and discriminatorMap Created: 24/Oct/10  Updated: 24/Nov/10  Resolved: 24/Nov/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0ALPHA1, 1.0.0ALPHA2, 1.0.0BETA1, 1.0.0BETA2
Fix Version/s: 1.0.0ALPHA1, 1.0.0ALPHA2, 1.0.0BETA1, 1.0.0BETA2

Type: Bug Priority: Major
Reporter: Dan Ordille Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None
Environment:

Symony2
Doctrine2 latest from github



 Description   

The discriminatorField and discriminatorMap options are ignored by both the YAML and XML drivers.

Example:
This mapping fails to store the discriminator in the type field and instead uses _doctrine_class_name as the discriminatorField the mapping also reverts to using class names.

 
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mongo-mapping>
    <document name="Application\Test\Document\Group" collection="groups">
        <field name="id" fieldName="id" id="true" />
        <field name="name" fieldName="name" type="string" />
        <embed-many field="people" discriminator-field="type">
            <discriminator-map>
                <discriminator-mapping class="Admin" value="Admin" />
                <discriminator-mapping class="User" value="User" />
            </discriminator-map>
        </embed-many>
    </document>
</doctrine-mongo-mapping>

I think that this is also a problem for referenced documents as well, as the code for the two is nearly identical.

I refactored addEmbedMapping and addReferenceMapping to call the same function addDocumentMapping
Commit can be found here http://github.com/dordille/mongodb-odm/commit/41ce2ee126ff7f82610130704dbec451384bfdd3



 Comments   
Comment by Jonathan H. Wage [ 24/Nov/10 ]

Merged! Thanks for the fix!





[MODM-28] xml mapping : embedded-document node is ignored, can't persist Created: 26/Jul/10  Updated: 27/Jul/10  Resolved: 27/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Major
Reporter: julien rollin Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   
 
//file Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php line 171

protected function _loadMappingFile($file)
    {
        $result = array();
        $xmlElement = simplexml_load_file($file);

        if (isset($xmlElement->document)) {
            foreach ($xmlElement->document as $documentElement) {
                $documentName = (string) $documentElement['name'];
                $result[$documentName] = $documentElement;
            }
        }
        
        return $result;
    }

embedded-document and mapped-superclass are ignored so embed documents are not persisted






[MODM-26] MongoCursor doesn't implement Countable interface Created: 13/Jul/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA2

Type: Improvement Priority: Major
Reporter: Bulat Shakirzyanov Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

this causes confusion when query returns empty array instead of MongoCursor object, meaning you can't use neither count($result) nor $result->count(), and have to check for the returned type explicitly



 Comments   
Comment by Jonathan H. Wage [ 19/Jul/10 ]

Fixed and added a MongoCursorTest file.





[MODM-25] AnnotationDriver.php Line 175 Created: 07/Jul/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Major
Reporter: Bulat Shakirzyanov Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

$mapping['fieldName'] should be replace with something else.
Maybe create a whole new metadata property, or map load methods as onLoad lyfecycle events...






[MODM-24] Hydratation of extra fields Created: 06/Jul/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Hydration
Affects Version/s: None
Fix Version/s: 1.0.0ALPHA2

Type: Improvement Priority: Minor
Reporter: Anonymous Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

I'm working on a project using MongoDB with ODM especially for the schemaless features.
So I have one collection with some default fields in my base class.
Every inherited class add fields but we're still in the same collection.

First, prior to save the document, I add the new mappings (imported from the inherited class) so they will be saved in the database. This part works fine.
The problem is that when the ODM hydrates the documents, it sticks to the $metadata->fieldMappings defined by the base class, and ignore the others.

I've made a quick patch for that, but it doesn't make any type cast, I didn't inspect the code deep enough to make it better.

In the Doctrine\ODM\MongoDB\Hydrator class (line 73) :

    public function hydrate(ClassMetadata $metadata, $document, $data)
    {
        $values = array();

        // Patch
        foreach ($data as $field => $value)
        {
          if(!array_key_exists($field, $metadata->fieldMappings))
          {
            $document->$field = $value;
          }
        }
        // end Patch

        foreach ($metadata->fieldMappings as $mapping) {
[...]



 Comments   
Comment by Jonathan H. Wage [ 19/Jul/10 ]

This is fixed now. Make sure your classes inheritance mapping is setup properly too if you have other problems.





[MODM-22] Document incorrectly scheduled for update Created: 28/Jun/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

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

Type: Bug Priority: Major
Reporter: Steven Surowiec Assignee: Jonathan H. Wage
Resolution: Cannot Reproduce Votes: 0
Labels: None


 Description   

I have the following documents:

Product:
product_id
sellable (dbref)

Sellable:
product (dbref)
seller (dbref)

Seller:
name

If I create a new Sellable for a seller the seller gets scheduled for update even if nothing has changed.The document persister correctly doesn't try to actually execute the update but Lifecycle events still get called. The flow is:

1. Schedule for update
2. Call _executeUpdate
3. Call preUpdate
4. Call BasicDocumentPersister::update(), which does nothing because of no actual changes
5. Call postUpdate.

preUpdate and postUpdate being called when there's no actual changes is causing problems. It seems like the proper course of action would be to either not schedule the document for update or check if there's any actual changes before calling preUpdate and postUpdate.



 Comments   
Comment by Jonathan H. Wage [ 05/Jul/10 ]

I will take a look at this. Can you try creating a test case that reproduces the issue?

Comment by Jonathan H. Wage [ 13/Jul/10 ]

Bulat, is this not fixed?

Comment by Jonathan H. Wage [ 19/Jul/10 ]

Any chance of a test case? Could you provide the documents you are using?





[MODM-21] AnnotationDriver doesn't allow custom types Created: 28/Jun/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Minor
Reporter: Steven Surowiec Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

Right now AnnotationDriver.php does not allow you to create custom types. You can with YAML and XML but the $types array on line ~142 of AnnotationDriver.php is hard coded so there's no way to get a custom type in there.






[MODM-19] Field annotation missing "name" support Created: 21/Jun/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: Mapping Drivers
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Minor
Reporter: Rabbit Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

Documentation states that field names can be overriden by using a "name" parameter but Doctrine throws exception.
Also there is a missing comma in the documentation between the type and name params.

From documentation:

http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/annotations-reference/en#ann_field

Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
/**
 * @Field(type="string" name="origin")
 */
protected $country;

My source code:

Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
    /**
     * @Field(type="string", name="password")
    **/
    protected $_password;

Exception:

BadMethodCallException:
Unknown property 'name' on annotation 'Doctrine\ODM\MongoDB\Mapping\Field'.






[MODM-17] Multiple array / object with same content/properties do not get persisted Created: 17/Jun/10  Updated: 19/Jul/10  Resolved: 19/Jul/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Major
Reporter: Pablo Godel Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

If I have a Collection field and try to add 2 values that are the same, the second value never gets saved to the document. Example code:

class User
{
  /** @Id */
  private $id;

  /** @String */
  private $name;

  /** @Collection */
  private $logs = array();

}
    $o = $dm->findOne(':User', array('name' => $arguments['name']));

    $found = true;

    if (!$o) {
      $found = false;
      $o = new User();
    }

    $o->setName($arguments['name']);

    $o->addLog( array('a' => 'b' ));

    $dm->persist($o);

    $dm->flush();

or a EmbeddedMany field, and try to add to add 2 objects with the same content the same thing happens:

class User
{
  /** @Id */
  private $id;

  /** @String */
  private $name;

  /** @EmbedMany(targetDocument="UserLog") */
  private $logs = array();
}
    $o = $dm->findOne(':User', array('name' => $arguments['name']));

    $found = true;

    if (!$o) {
      $found = false;
      $o = new User();
    }

    $o->setName($arguments['name']);

    $l = new UserLog();

    $l->setMsg('Testing');

    $o->addLog($l);

    $dm->persist($o);

    $dm->flush();

If I change $l->setMsg('Testing'.time());

then it adds all the instances.



 Comments   
Comment by Jonathan H. Wage [ 19/Jul/10 ]

Seems to be working now.





[MODM-16] loadById failing on custom ids Created: 17/Jun/10  Updated: 17/Jun/10  Resolved: 17/Jun/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Major
Reporter: Steven Surowiec Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

DocumentManager::loadByID is failing on custom ids right now because it's checking for the custom id flag on the metadata and converting to \MongoID. It should probably be using the new $class->getPHPIdentifierValue method instead.



 Comments   
Comment by Steven Surowiec [ 17/Jun/10 ]

Fixed in http://github.com/opensky/mongodb-odm/commit/78ac8bf8e31e91f88d2cdd7918db3ebaafe76a63

Comment by Jonathan H. Wage [ 17/Jun/10 ]

Thanks for the issue and fix!





[MODM-14] Default database when @Document annotation does not contain a db attribute. Created: 11/Jun/10  Updated: 11/Jun/10  Resolved: 11/Jun/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Minor
Reporter: Henrik Bjornskov Assignee: Jonathan H. Wage
Resolution: Can't Fix Votes: 0
Labels: None


 Description   

When a Document is annotated with @Document(collection="test") and is missing the db attribute the ODM defaults to mongo_dev. What i expected was it defaulted to the database name given when creating a connection.



 Comments   
Comment by Jonathan H. Wage [ 11/Jun/10 ]

We have no way to retrieve the database you connected to so you have to configure it by setting $config->setDefaultDB('db_name');





[MODM-13] Problems with merge() Created: 10/Jun/10  Updated: 10/Jun/10  Resolved: 10/Jun/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Major
Reporter: Florian Kubis Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None
Environment:

OSX, HEAD



 Description   

while doing a merge, I got some PHP errors.
Seems like these steps fix the problem:
1. Change line 1215 of UnitOfWork.php to
$id = $class->getIdentifierValue($document);
it was ValueS before

2. in function _cascadeMerge starting in line 1464 of UnitOfWork.php
change the inner calls from:
$this->_cascadeMerge($relatedDocument, $visited);
To:
$this->_cascadeMerge($relatedDocument, $managedCopy, $visited);

I didn't look deeper into ODM, just tried this to things and it seems to work now, so please excuse if it's bs ...



 Comments   
Comment by Jonathan H. Wage [ 10/Jun/10 ]

Thanks for reporting the issue!





[MODM-12] Undefined variable error Created: 09/Jun/10  Updated: 09/Jun/10  Resolved: 09/Jun/10

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0ALPHA1
Fix Version/s: 1.0.0ALPHA2

Type: Bug Priority: Major
Reporter: Steven Surowiec Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

In UnitOfWork::_computeAssociationChanges there are several references to $document but $document is never declared in that method, or passed into it. From looking at ORM it looks like $entry is the right variable to be using here.



 Comments   
Comment by Steven Surowiec [ 09/Jun/10 ]

Fixed in http://github.com/opensky/mongodb-odm/tree/MODM-12





Generated at Wed Sep 17 07:36:34 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.