[DDC-3745] OneToOne identity through foreign entity exception on flush Created: 22/May/15  Updated: 22/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Dawid Nowak Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Also asked at SO: https://stackoverflow.com/questions/30402203
I'm adding it here as well as an issue here, because I believe it just might be Doctrine's bug.


I have `User` and `UserProfile` OneToOne–related Doctrine ORM entities. They should always exist as a pair, there should be no `User` without `UserProfile`.

User should get its id from autoincrement, while UserProfile should have User's id. So they both should have the same id and there is no other column to set up the relationship ([Doctrine docs: Identity through foreign Entities](https://doctrine-orm.readthedocs.org/en/latest/tutorials/composite-primary-keys.html#identity-through-foreign-entities)).

User's id is both a primary key (PK) and foreign key (FK) at the same time.

I managed to set it up, but it requires that User is saved first and only later UserProfile is created and saved in a separate step.

What I want is that UserProfile is always created with User, in the constructor, but if I do that, I get this exception:

`Doctrine\ORM\ORMInvalidArgumentException: The given entity of type 'AppBundle\Entity\UserProfile' (AppBundle\Entity\UserProfile@0000000052e1b1eb00000000409c6f2c) has no identity/no id values set. It cannot be added to the identity map.`

Please see code below – it works, but not the way I want. The php comments show what I want to achieve.

Test.php
    /**
     * It works, both saving and loading.
     * BUT, it requires that I create and save UserProfile 
     * in a separate step than saving User step.
     */
    
    // create and save User
    $user = new User();
    $objectManager->persist($user);
    $objectManager->flush();
    
    // create and save UserProfile (this should be unnecessary)
    $user->createProfile()
    $objectManager->flush();
User.php
    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * @ORM\Entity(repositoryClass="AppBundle\Entity\UserRepository")
     * @ORM\Table(name="users")
     */
    class User
    {
    	/**
    	 * @var int
    	 *
    	 * @ORM\Column(name="uid", type="integer")
    	 * @ORM\Id
    	 * @ORM\GeneratedValue(strategy="AUTO")
    	 */
    	private $id;
    	
    	/**
    	 * It's NULL at first, I create it later (after saving User).
    	 * 
    	 * @var UserProfile|null
    	 *
    	 * @ORM\OneToOne(targetEntity="UserProfile", mappedBy="user", cascade="persist")
    	 */
    	private $profile = null;
    	
    	public function __construct()
    	{
    		// I want to create UserProfile inside User's constructor,
    		// so that it is always present (never NULL):
    		//$this->profile = new UserProfile($this);
    		
    		// but this would give me error:
    		//
    		// Doctrine\ORM\ORMInvalidArgumentException: 
    		// The given entity of type 'AppBundle\Entity\UserProfile' 
    		// (AppBundle\Entity\UserProfile@0000000058af220a0000000079dc875a)
    		// has no identity/no id values set. It cannot be added to the identity map.
    	}
    
    	public function createProfile()
    	{
    		$this->profile = new UserProfile($this);
    	}	
    }
UserProfile.php
    
    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="profiles")
     */
    class UserProfile
    {
    	/**
    	 * – UserProfile's "uid" column points to User's "uid" column
    	 * – it is PK (primary key)
    	 * - it is FK (foreign key) as well
    	 * – "owning side"
    	 *
    	 * @var User
    	 *
    	 * @ORM\Id
    	 * @ORM\OneToOne(targetEntity="User", inversedBy="profile")
    	 * @ORM\JoinColumn(name="uid", referencedColumnName="uid", nullable=false)
    	*/
    	private $user;
        
    	public function __construct(User $user)
    	{
    		$this->user = $user;
    	}    
    }





[DDC-3744] [GH-1412] Added RANDOM() function to DQL Created: 22/May/15  Updated: 22/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: New Feature Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of cverges-ch:

Url: https://github.com/doctrine/doctrine2/pull/1412

Message:

Corresponds with generic platform support for a random number generator mechanism typically implemented by most DBMS.

See pull request at https://github.com/doctrine/dbal/pull/865

Use of RAND(), random(), DBMS_RANDOM.VALUE, or whatever the platform provides as a random number generator can be essential to some business logic. This adds generic platform support for this mechanism and introduces a new DQL keyword "RANDOM()".

DBAL: https://github.com/doctrine/dbal/pull/865
DQL: https://github.com/doctrine/doctrine2/pull/1412






[DDC-3383] [GH-1179] Fix embeddables class metadata (work-in-progress) Created: 10/Nov/14  Updated: 22/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1179

Message:

ClassMetadataInfo is returning more than one result in getFieldNames() for the embeddables properties. This method is used by DoctrineModule\Stdlib\Hydrator\DoctrineObject in the extraction process.

Since its returning a number of results equal the number of properties of the embedded object, it will never find the correct setter for the extraction and that causes that property to be removed from the extracted array.

I was able to solve the issue by hacking into the getFieldNames() for testing and merging the duplicated entries, and then the object was successfully extracted.

By digging into the code, i found out that there is a mapEmbedded(), but instead of using that for embeddeds, its using the default mapField, which may be the root cause of the problem.

  • [x] Hack into the getFieldNames() method to see if the expected solution would work
  • [x] Remove multiple class declaration in the same file from the files i'll work with
  • [x] Create a failing testcase
  • [ ] Create a solution


 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1179] was labeled:
https://github.com/doctrine/doctrine2/pull/1179

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1179] was labeled:
https://github.com/doctrine/doctrine2/pull/1179

Comment by Doctrine Bot [ 22/May/15 ]

A related Github Pull-Request [GH-1179] was closed:
https://github.com/doctrine/doctrine2/pull/1179





[DDC-3742] Use UTCDatetimeType with lifecycle callbacks Created: 22/May/15  Updated: 22/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: pablo Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: dbal, orm
Environment:

Fedora 20 x64 with Phalcon 2.0 and doctrine downloaded via composer:
"doctrine/orm": "2.*",
"doctrine/mongodb-odm": "dev-master",



 Description   

I'm trying to save my entities (yaml), which have lifecyclecallbacks with a createdAt and updatedAt UTCDatetimeType fields. If I save them with prePersist or preUpdate, the insert of new rows into the mysql database fails because of blank date fields, but they are already populated in my entity.

If I replace the UTCDateTimeType by datetime, it works.



 Comments   
Comment by pablo [ 22/May/15 ]

I'm using UTCDateTimeType from: http://doctrine-orm.readthedocs.org/en/latest/cookbook/working-with-datetime.html

It makes a $value->format($format, $timezone)

I was passing a \Datetime object, so format only has one parameter, not 2...Then, Or I'm passing an unexpected $value or the format method is not properly coded there.

So, I've modified convertToDatabaseValue to the following:

        if ($value === null) {
            return null;
        }

        if (is_null(self::$utc)) {
            self::$utc = new \DateTimeZone('UTC');
        }

        if (!($value instanceof \DateTime)) {
            $value = \DateTime::createFromFormat(
                $platform->getDateTimeFormatString(),
                $value,
                self::$utc
            );
        }

        $value->setTimeZone(self::$utc);

        $val = $value->format($platform->getDateTimeFormatString());

        return $val;
Comment by Marco Pivetta [ 22/May/15 ]

pablo what exactly is the action to be taken here? It's unclear to me.

Comment by pablo [ 22/May/15 ]

I replaced the metod convertToDatabaseValue from http://doctrine-orm.readthedocs.org/en/latest/cookbook/working-with-datetime.html with mine.

For example:

<code>
date_default_timezone_set('Europe/Madrid');
$expireAt = new \DateTime();
$entity = newEntity();
$entity->setExpireAt($expireAt);

$this->em->persist($entity);
$this->em->flush();
</code>

My expireAt field is UTCDateTimeType, so it will be converted from my Europe/Madrid timezone to UTC. But using the code from URL it doesn't works because ->format() method has 2 parameters instead of one.





[DDC-3743] There is a BC break in the ORM 2.5 in the DQL parser Created: 22/May/15  Updated: 22/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Christophe Coevoet Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: dql


 Description   

The following DQL query is working fine on 2.4 but breaks on 2.5:

SELECT COUNT(l) FROM Incenteev\WebBundle\Entity\Discussion\Liker l INNER JOIN l.message m INNER JOIN m.thread t WHERE t.space IN (:space_ids) AND l.date >= :from

This is the exception triggered in 2.5:

[Semantical Error] line 0, col 13 near 'l) FROM Incenteev\WebBundle\Entity\Discussion\Liker': Error: Invalid PathExpression. Must be a StateFieldPathExpression. 

The exception happens in Parser->processDeferredPathExpressions.

The Liker class has a compound identifier based on 2 relations.

I suspect it is related to https://github.com/doctrine/doctrine2/pull/1122



 Comments   
Comment by Christophe Coevoet [ 22/May/15 ]

I'm not sure it is a BC break though. Looking at the SQL generated in 2.4, it was not counting the right thing (is was counting only the message ids, not the combination message id/user id being the primary key.





[DDC-1078] Cannot select inverse side of many-to-many relationship with a many-to-many DQL query Created: 25/Mar/11  Updated: 21/May/15  Resolved: 25/Mar/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.0.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Daniel Moore Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

I have two classes - Page and SiteVersion, which have a many to many relationship. Only SiteVersion is aware of the relationship (because the site is modular and I want to be able to take away and drop in the module that SiteVersion belongs to).

I do not seem to be able select pages based on criteria of SiteVersion.

Using this query on the cli tool:

SELECT p FROM SiteVersion v JOIN v.pages p WHERE v.id = 5 AND p.slug='index'

Gives me the error:

[Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col -1 near 'SELECT p FROM': Error: Cannot select entity through identification variables without choosing at least one root entity alias.

Using the alternative join syntax does not work either:

SELECT p FROM SiteVersion v, Page p WHERE v.id = 5 AND p.slug='index' AND v.pages = p

Which gives me:

[Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col 98 near 'pages = p': Error: Invalid PathExpression. StateFieldPathExpression or SingleValuedAssociationField expected.



 Comments   
Comment by Benjamin Eberlei [ 25/Mar/11 ]

This is not a bug, it is not supported as per the Exception Message is already telling you.

You have to have the entity in the FROM clause that you are SELECTing. Just reverse the condition and use the inverse side of bidirectional assocation to do the query.

Comment by Benjamin Eberlei [ 25/Mar/11 ]

Ah, just reading the association is just unidirectional. In this case the query you want to do is not possible. Speaking semantically, if you omit one direction of a query, then Doctirne does not allow you to query this way. Just about right.

Comment by Miguel Alvarez Rodriguez [ 21/May/15 ]

I have the exact same problem with a many to many bidirectional association.
This would be very easy to do with SQL.
Can't it be done with DQL?

---
BlogEntry:
  type: entity
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    title:
      type: string
    body:
      type: text
    published:
      type: boolean
  manyToMany:
    tags:
      targetEntity: Tag
      inversedBy: blogEntry
...
---
Tag:
  type: entity
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    name:
      type: string
  manyToMany:
    blogEntry:
      targetEntity: BlogEntry
      mappedBy: tags
...

There is a join table like:

CREATE TABLE blogentry_tag (blogentry_id INTEGER NOT NULL, tag_id INTEGER NOT NULL, PRIMARY KEY(blogentry_id, tag_id), CONSTRAINT FK_AAA8A8A2228815BC FOREIGN KEY (blogentry_id) REFERENCES BlogEntry (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_AAA8A8A2BAD26311 FOREIGN KEY (tag_id) REFERENCES Tag (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE);




[DDC-3741] [GH-1411] Allow null to be passed to setHydrationCacheProfile Created: 20/May/15  Updated: 20/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1411

Message:

Currently null can be passed and is set as default, however if you do this you get an exception. This allows null to be passed and set.

There is an if statement later on to see if $this->_hydrationCacheProfile is null so it seems logical you can set it to be null.






[DDC-875] Merge can sometimes add the same entity twice into a collection Created: 11/Nov/10  Updated: 19/May/15  Resolved: 11/Mar/12

Status: Closed
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0-BETA4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Dave Keen Assignee: Roman S. Borschel
Resolution: Cannot Reproduce Votes: 1
Labels: None

Attachments: File multipleaddmerge.diff     File multipleaddmerge2.diff    

 Description   

When merging some cascade merge object-graphs, the same entity in a ManyToMany association can be put into a collection twice during doMerge.

The attached patch should stop this from happening.



 Comments   
Comment by Benjamin Eberlei [ 15/Nov/10 ]

which conditions lead to this problem? I want to write a test for it

Comment by Benjamin Eberlei [ 15/Nov/10 ]

not doint the unwrap() but add() directly was a bugfix for one of your other issues .Why is unwrap in here again?

Comment by Dave Keen [ 20/Dec/10 ]

Oops - that was a mistake. I have attached multipleaddmerge2.diff which no longer uses unwrap to add the element.

Comment by Benjamin Eberlei [ 27/Dec/10 ]

That is exactly the same code in the patch, the lines are just formatted differently.

Comment by Dave Keen [ 06/Jan/11 ]

Sorry, I am still getting the hang of git and diff and maybe what I put in there isn't what I meant to. I have now pushed the code to the DDC-875 branch on my ccapndave/doctrine2 fork on GitHub, hopefully this works better.

As far as I can tell I am using unwrap() in order to check whether the element already exists in the array, but then calling >add() directly on the PersistentCollection rather than the ArrayCollection, triggering $this>changed().

Comment by Benjamin Eberlei [ 26/Feb/11 ]

It seems even this issue is caused by multiple calls to persist. I cannot reproduce this with just a single bidirectional cascade merge.

Comment by Alexander [ 11/Mar/12 ]

We cannot reproduce this error and haven't had similar complaints ever-since. Feel free to open a new issue with a failing testcase.

Comment by Vivek Soni [ 19/May/15 ]

I am also facing this issue, I have String as primary key for a table (brand table) getting this error

A new entity was found through the relationship 'Application\Entity\Pcds#brandCode' that was not configured to cascade persist operations for entity: Company\Model\Entity\Brand@000000003beb6d2200007ffa52ab9a34. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade=

{"persist"}

). If you cannot find out which entity causes the problem implement 'Company\Model\Entity\Brand#__toString()' to get a clue.

If i var_dump this $brand entity it shows that it have primary key inside it.

Comment by Vivek Soni [ 19/May/15 ]

This stackoverflow question solved my problem, instead of persist, i had to do merge

http://stackoverflow.com/questions/18215975/doctrine-a-new-entity-was-found-through-the-relationship





[DDC-3681] [GH-1378] Feature to force-increment entity version Created: 09/Apr/15  Updated: 18/May/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers, ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: New Feature Priority: Minor
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: persister, unitofwork, versioned

Issue Links:
Dependency
depends on DDC-3683 [GH-1380] Fix issue with second-level... Open
Duplicate
is duplicated by DDC-3640 Force version increment via mapped pr... Resolved

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1378

Message:

Submitting for feedback and experimentation.

The major use-case for this involves using certain entities as the versioned-gatekeepers for changes that don't directly live on the same entity. For example, using the version of a `PurchaseOrder` to control changes to any of its child `PurchaseOrderLineItem` objects.



 Comments   
Comment by Doctrine Bot [ 18/May/15 ]

A related Github Pull-Request [GH-1378] was closed:
https://github.com/doctrine/doctrine2/pull/1378

Comment by Doctrine Bot [ 18/May/15 ]

A related Github Pull-Request [GH-1378] was reopened:
https://github.com/doctrine/doctrine2/pull/1378





[DDC-3740] \Doctrine\ORM\LazyCriteriaCollection::count() returns "0" instead of 0 Created: 16/May/15  Updated: 16/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Carsten Bleicker Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Getting the count of a LazyCriteriaCollection results in numerical string instead of integer.






[DDC-3739] [GH-1410] Skip generate lifecycle methods if they already generated Created: 15/May/15  Updated: 15/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1410

Message:

This happens when I use one lifecycle method in prePersist and preUpdate together. Like
```yml
lifecycleCallbacks:
prePersist: [setCreatedAtValue, setUpdatedAtValue]
preUpdate: [setUpdatedAtValue]
```

Before generator generate two methods with the same names.

@Ocramius, what do you think what is better way to write test for this?
Should I test generateEntityLifecycleCallbackMethods directly?






[DDC-3738] [GH-1409] Added PHPDoc return type false of next method in Hydration/IterableResult Created: 15/May/15  Updated: 15/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1409

Message:

Because hydrateRow can return false, too. The PHPDoc return type of the next method has return false in addition to array.






[DDC-3737] [GH-1408] [doc] Remove unused variable from sample code Created: 14/May/15  Updated: 14/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1408

Message:

Removes lexer since it's not used.






[DDC-3736] Support for Objects as Identifiers with Strategy AUTO Created: 14/May/15  Updated: 14/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

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


 Description   

According to the official documentation (http://doctrine-orm.readthedocs.org/en/latest/changelog/migration_2_5.html#support-for-objects-as-identifiers) using objects as Identifiers work .

The issue is that if in the mapping settings generator strategy is set to AUTO, the BasicEntityPersister won't hydrate the id to an Object , but keep it as a scalar.

\\Doctrine\ORM\Persisters\Entity::executeInserts() , line 257
$generatedId = $idGenerator->generate($this->em, $entity);
$id = array(
    $this->class->identifier[0] => $generatedId
);
$postInsertIds[] = array(
    'generatedId' => $generatedId,
    'entity' => $entity,
);

This could be tracked down to the IdGenerator :

\\Doctrine\ORM\Id\IdentityGenerator::generate() , line 53
public function generate(
        EntityManager $em, $entity)
    {
        return (int)$em->getConnection()->lastInsertId($this->sequenceName);
    }


 Comments   
Comment by Andrei Mocanu [ 14/May/15 ]

Workaround:

id:
        id:
            type: UserId
            column: id
            generator:
                strategy: CUSTOM
            customIdGenerator:
                class: MyApp\ORM\Id\ObjectIdentityGenerator

Create a ObjectIdentityGenerator that extends AbstractIdGenerator and implement generate:

public function generate(
        EntityManager $em, $entity)
    {
        $entityClass = get_class($entity);
        $idFieldName = $em->getClassMetadata($entityClass)->getSingleIdentifierColumnName();
        $reflection = new ReflectionClass($entityClass);
        $params = $reflection->getConstructor()->getParameters();
        foreach ($params AS $param) {
            if ($param->getName() === $idFieldName && $idClass = $param->getClass()) {
                return new $idClass->name((int) $em->getConnection()->lastInsertId($this->sequenceName));
            }
        }
        return (int)$em->getConnection()->lastInsertId($this->sequenceName);
    }




[DDC-3735] Problem with Collate Created: 13/May/15  Updated: 13/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers, ORM
Affects Version/s: 2.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Hugo Henrique Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: dbal, mapping, mysql, schematool
Environment:

development



 Description   

I'm using Migrations and always when a new version changes in my schema in action `up` SQL removes the definition of the table COLLATE for example:

Version20150513194922.php
public function up(Schema $schema)
{
    $this->addSql('ALTER TABLE customer CHANGE user_id user_id CHAR(36) DEFAULT NULL COMMENT \'(DC2Type: guid)\'');
}

public function down(Schema $schema)
{
    $this->addSql('ALTER TABLE customer CHANGE user_id user_id CHAR(36) NULL DEFAULT COLLATE utf8_unicode_ci COMMENT \'(DC2Type: guid)\'');
}
User.php
/**
 * @ORM\Table(name="user")
 * @ORM\HasLifecycleCallbacks
 */
class User
{
    /**
     * @ORM\Id
     * @ORM\Column(type="guid", options={"unsigned"=true})
     * @ORM\GeneratedValue(strategy="UUID")
     */
    protected $id;

Customer.php
/**
 * @ORM\Entity
 * @ORM\Table(name="customer")
 */
class Customer
{
    /**
     * @ORM\Id
     * @ORM\Column(type="bigint", options={"unsigned"=true})
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\OneToOne(targetEntity="User")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
     */
    protected $user;

schema.sql
CREATE TABLE `user` (
  `id` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:guid)',
  `name` varchar(60) COLLATE utf8_unicode_ci NOT NULL,
  `username` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,
  `username_canonical` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `email_canonical` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `salt` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_8D93D649E7927C74` (`email`),
  UNIQUE KEY `UNIQ_8D93D649F85E0677` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `customer` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '(DC2Type:guid)',
  `gender` varchar(1) COLLATE utf8_unicode_ci DEFAULT NULL,
  `zipcode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
  `birthday` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_705B3727A76ED395` (`user_id`),
  CONSTRAINT `FK_705B3727A76ED395` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;





[DDC-3120] Warning: Erroneous data format for unserializing PHP5.6+ Created: 11/May/14  Updated: 13/May/15  Resolved: 27/Aug/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.5, 2.4.6
Security Level: All

Type: Bug Priority: Critical
Reporter: Cornelis Brouwers Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: mapping, orm
Environment:

Webserver Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.6.0beta2

and

PHP-CLI (Win32) PHP/5.6.0beta2


Issue Links:
Duplicate
is duplicated by DDC-3252 [GH-1109] DDC-3120 - PHP 5.6-RC3 comp... Resolved
Reference
is referenced by DDC-3156 [GH-1050] DDC-3120 -- Catch Reflectio... Resolved
is referenced by DDC-3339 [GH-1154] Hotfix/php 5.6 serializatio... Resolved

 Description   

Hi all,

There seems to be something strange going on in the method newInstance() of the class \Doctrine\ORM\Mapping\ClassMetadataInfo.

The original class method looks like this:

\Doctrine\ORM\Mapping\ClassMetadataInfo#newInstance()

    {
        if ($this->_prototype === null) {
            $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
        }

        return clone $this->_prototype;
    }

What happens now when a class that implements \Serializable is that a "Warning: Erroneous data format for unserializing" shows up and the function unserialize() returns false.

That is because a class that implements \Serializable is expected to have the letter 'C' in the serialize string instead of the letter 'O'.

I've made a quick work-around like this:

\Doctrine\ORM\Mapping\ClassMetadataInfo#newInstance()

    {
        if ($this->_prototype === null) {
            $this->_prototype = @unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
            if ($this->_prototype === false) {
                $this->_prototype = unserialize(sprintf('C:%d:"%s":0:{}', strlen($this->name), $this->name));
            }
        }

        return clone $this->_prototype;
    }

That seems to work in my isolated tests and with Symfony2 and Doctrine2 and FOSUserBundle together.

I've noticed this because the Model\User class from FOSUserBundle implements \Serializable.

I had to implement a check in Model\User class because when using 'C:%d:"%s":0:{}' the $serialized parameter of the unserialize method in the Model\User class is a empty string then.

That warning seems only to happen with PHP5.6+. PHP5.5.12 and below doesn't show that warning.

I hope someone can shine some light on this, thank you,

Cornelis.



 Comments   
Comment by Marco Pivetta [ 11/May/14 ]

Indeed, for PHP 5.4+ we should use

ReflectionClass#newInstanceWithoutConstructor()
Comment by Cornelis Brouwers [ 11/May/14 ]

Just tested it. That works as expected, far more better then the dirty hacks I did, thanks a lot!

Any idea when this would be implemented into the code?

Comment by Marco Pivetta [ 11/May/14 ]

Send a pull request and I'll merge it later today (we could also need a failing test with an entity implementing the Serializable interface)

Comment by Evert Harmeling [ 30/May/14 ]

Seems to be a problem in the latest PHP 5.4 version too.

https://github.com/doctrine/doctrine2/pull/1045/

Comment by Doctrine Bot [ 30/May/14 ]

A related Github Pull-Request [GH-1045] was closed:
https://github.com/doctrine/doctrine2/pull/1045

Comment by Julian Reyes Escrigas [ 02/Jun/14 ]

I am facing this same error i have PHP 5.5.13, I'm using Symfony, Doctrine ORM and FOSUserBUndle

Comment by Marco Pivetta [ 02/Jun/14 ]

Julian Reyes Escrigas the patch landed in master (2.5.x) for now.

Comment by Marco Pivetta [ 02/Jun/14 ]

Merged via DDC-3147

Comment by Thomas Buhk [ 04/Jun/14 ]

When can we expect the version with this bugfix?

Comment by Anthony Rey [ 08/Jun/14 ]

Why don't you tag 2.4.3 version with this fix ? Because the error is already present in PHP 5.5.13 which is a stable version and it's a blocking issue when you're using FOSUserBundle for example. There is also no opened issue refering this version and the due date is in april.

Comment by Jovan Perovic [ 19/Jun/14 ]

I'm still seeing this bug, although my PHP_VERSION_ID is 50600

So, version based condition is no good...

Comment by Marco Pivetta [ 19/Jun/14 ]

The approach to be taken for 50600 is still under discussion in php-internals.

Comment by Cornelis Brouwers [ 20/Jun/14 ]

Hi all,

I've just downloaded PHP5.6RC1 and updated doctrine and the error is back indeed.

A little peek at the code starting on line 866 of file Doctrine\ORM\Mapping\ClassMetadataInfo.php shows this:

    public function newInstance()
    {
        if ($this->_prototype === null) {
            if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
                $this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
            } else {
                $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
            }
        }

        return clone $this->_prototype;
    }

As can be seen, PHP5.6 is out of the picture, it only checks for the exact versions 5.4.29 and 5.5.13.

So for the code to work correctly on PHP5.6 one can add PHP5.6 to the test condition, or just skip the test all together if you don't mind the old PHP5.3. According to PHP, ReflectionClass::newInstanceWithoutConstructor is available since PHP >= 5.4.0.

Greetings, Cornelis.

Comment by Marco Pivetta [ 21/Jun/14 ]

As I already pointed out, this is still being discussed in php internals. See http://news.php.net/php.internals/75009

This won't be dealt with in 5.6 until there's either a stable release or internals decides what has to be done.

Comment by Marco Pivetta [ 21/Jun/14 ]

Also, ReflectionClass#newInstanceWithoutConstructor() still doesn't cover the pre-existing "hack" using unserialize, so we're still waiting for a reliable API from PHP core.

Comment by Chase Noel [ 23/Jul/14 ]

Using PHP 5.6RC2 and ORM 2.4.4 I am still experiencing this issue. I have also tested with PHP 5.5.15 and I am still getting the issue. Do i need to be using a different build of ORM to have the fix applied?

Comment by pascall [ 23/Jul/14 ]

Hi,
I'm using 5.6.0beta3 and ORM 2.4.4 and i have the same probleme
Warning: Erroneous data format for unserializing .. in orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 872

and in current code in ClassMetadataInfo.php line 872 is :

public function newInstance()
{
if ($this->_prototype === null) {
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513)

{ $this->_prototype = $this->reflClass->newInstanceWithoutConstructor(); }

else {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}
}

return clone $this->_prototype;
}

Comment by Evert Harmeling [ 23/Jul/14 ]

As stated by Marco Pivetta; "This won't be dealt with in 5.6 until there's either a stable release or internals decides what has to be done.". And besides that 5.6 still is in development, not stable.
If you still want to use 5.6 you can fork the code and extend the 5.4 / 5.5 check to support 5.6.

Comment by Chase Noel [ 23/Jul/14 ]

5.6 has an RC which should mean a stable API, and that only bugs will be fixed before an official stable release?

Comment by Evert Harmeling [ 23/Jul/14 ]

Looking at http://news.php.net/php.internals/75966 it's still being discussed, and they are planning to have it fixed in RC3.

Comment by Marco Pivetta [ 23/Jul/14 ]

Internals still didn't get to a clear decision. Until then, we won't support 5.6 officially.

Comment by Ronan [ 24/Jul/14 ]

Same error encountered with PHP 5.5.13 (cli) (built: May 30 2014 10:43:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

(PHP 5.5 installed via http://php-osx.liip.ch/)

Comment by Marco Pivetta [ 24/Jul/14 ]

Ronan what D2 version? We fixed it for 2.4.x (temporarily)

Comment by Ronan [ 24/Jul/14 ]

My bad: reading my composer.lock: doctrine/orm, v2.4.2, ref 0363a5548d9263f979f9ca149decb9cfc66419ab, "time": "2014-02-08 16:35:09"... Well.. this is was an old one !

`composer update` fixed it. Sorry for disturbing.

Comment by Chase Noel [ 12/Aug/14 ]

Im still getting this error running php 5.6RC2 and the dev-master(6ac19b04bfbd7a97aad5ed8c2abd6279ff5e0022) build of D2/orm. Am i missing something?

Comment by Marco Pivetta [ 12/Aug/14 ]

This was semi-fixed in PHP5.6-RC3, and it will be patched into ORM once doctrine/instantiator is out

Comment by Chase Noel [ 12/Aug/14 ]

Ok good to know. Thanks

Comment by Marco Pivetta [ 13/Aug/14 ]

Not yet fixed for PHP 5.6

Comment by Marco Pivetta [ 14/Aug/14 ]

Provided a hotfix proposal at https://github.com/doctrine/doctrine2/pull/1109 - please check it out with PHP 5.6.0-RC3 or later

Comment by Doctrine Bot [ 27/Aug/14 ]

A related Github Pull-Request [GH-1109] was closed:
https://github.com/doctrine/doctrine2/pull/1109

Comment by Marco Pivetta [ 27/Aug/14 ]

Due to a new introduced dependency, this issue will only be solved for PHP 5.6 in 2.5.0 and later.

Comment by Doctrine Bot [ 28/Aug/14 ]

A related Github Pull-Request [GH-1109] was assigned:
https://github.com/doctrine/doctrine2/pull/1109

Comment by Dominik Zogg [ 10/Sep/14 ]

@ocramius would be great if there where backports for 2.4 and 2.3

Comment by Attila Bukor [ 28/Sep/14 ]

I agree with Dominik, we'd like to use the latest stable version and would need this patch.

Comment by Marco Pivetta [ 06/Oct/14 ]

This has been backported in DDC-3339

Comment by sysko [ 13/May/15 ]

I still have this error even 2.5.0+ and PHP5.6+
https://travis-ci.org/allan-simon/oauth2-symfony2-vagrant-fosuserbundle/jobs/62429219





[DDC-3662] "Improve efficiency of One-To-Many EAGER" still do 2 db request when Criteria::$firstResult set Created: 04/Apr/15  Updated: 13/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Fedir Zinchuk Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

In Doctrine 2.5 when I have entity with association One-To-Many and fetch="EAGER", doctrine still do 2 db request , when use Criteria with Criteria::$firstResult and Criteria::$maxResults

last time I tested on Doctrine 2.5 RC 1, and there this have work perfect: doctrine have use JOIN to load association.

I think it get broken between 2.5 rc1 and 2.5

for load the items I use

$criteria->setFirstResult(0);// this and next, cause 2 request per item
$criteria->setMaxResults(10);
$items = $repositiry->matching($criteria);


 Comments   
Comment by Marco Pivetta [ 04/Apr/15 ]

Fedir Zinchuk could you come up with an example?

This looks like logic that goes through the paginator, if I'm not mistaken...

Comment by Fedir Zinchuk [ 05/Apr/15 ]

Example you have entities: Gallery and Image,
where Gallery have field 'images' that is bidirectional association One-To-Many and fetch="EAGER" with Image,
and you load the galleries using matching($criteria), then:

This code will do 1 db request for load Galleries list + 1 db request for each Gallery item, to load its Images

$repositiry = $em->getRepository('Gallery');
$criteria  = Criteria::create();
$criteria->where(Criteria::expr()->eq("published", 1));
$criteria->setFirstResult(0);
$criteria->setMaxResults(20);

$galleries = $repositiry->matching($criteria);

This code will do 1 db request for load All: Galleries and its Images

$repositiry = $em->getRepository('Gallery');
$criteria  = Criteria::create();
$criteria->where(Criteria::expr()->eq("published", 1));

$galleries = $repositiry->matching($criteria);

I use setFirstResult() and setMaxResults() because I use external pagination not from Doctrine.

After small investigation, I found that it because $this->currentPersisterContext->handlesLimits there https://github.com/doctrine/doctrine2/blob/e57be9da5e0c6bb31ac286d213e204784a34aa43/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php#L1221

Comment by Fedir Zinchuk [ 13/May/15 ]

seems this issue introduced in that commit https://github.com/doctrine/doctrine2/commit/a37fa97be35e446a84d43c7790d54e2a13e5570b

after I remove

if ((($assoc['type'] & ClassMetadata::TO_MANY) > 0) && $this->currentPersisterContext->handlesLimits) {
      continue;
}

I get 1 DB request, but I not sure which impact it could on other cases :/





[DDC-3734] [GH-1407] Add return to removeMethodTemplate Created: 13/May/15  Updated: 13/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1407

Message:






[DDC-3733] [GH-1406] add default value for GeneratedValue Created: 12/May/15  Updated: 12/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1406

Message:

The "strategy" attribute on the GeneratedValue annotation is actually not required but optional. It works fine when the attribute is not specified.

The default value for this attribute is AUTO.






[DDC-3732] Entity with string @id can't be fetches Created: 10/May/15  Updated: 11/May/15  Resolved: 10/May/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Peter Zwegat Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: mysql, orm
Environment:

MySQL



 Description   

I defined an entity id field with the annotation:

@ORM\Id
@ORM\Column(type="string", length=2)

It's not possible to fetch the entity neither with ->find() nor manually with a query builder (quoted etc., tried everything).

$qb->where('l.id = ?1');
$qb->setParameters([
1 => $this->getEntityManager()->getConnection()->quote($id)
]);

This return just null even if the entity with the given id exists.

When I not quote the passed id value it, I become this error:

Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 121 near 'fi': Error: 'fi' is not defined. (/..../vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php: 63)

'fi' ist just the country identifier here that is the entity id.



 Comments   
Comment by Marco Pivetta [ 10/May/15 ]

Quoting parameters explicit is not necessary.

Also, quoting parameters is not needed in DQL, as DQL is translated by looking at mappings anyway.

Comment by Peter Zwegat [ 10/May/15 ]

Yeah I only quoted the id for test purposes.
I go a step back:
->find('de') throws the exception that I posted in the issue.

String Id's are possible normally not?

Comment by Marco Pivetta [ 10/May/15 ]

Peter Zwegat yes, it is allowed, but what exception are you getting?

Comment by Peter Zwegat [ 11/May/15 ]

This one when I try to find an entity by it's id:

Doctrine\ORM\Query\QueryException: [Semantical Error] line 0, col 121 near 'fi': Error: 'fi' is not defined. (/..../vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php: 63)

'fi' is here the key. Just used the ->find method.

Comment by Marco Pivetta [ 11/May/15 ]

Please show some actual code in a gist - I'm doing guesswork here :-P





[DDC-3731] [GH-1405] EntityManager#getReference throw ORMException for unrecognized id Created: 09/May/15  Updated: 09/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1405

Message:

  • Unreachable statements have been removed
  • Throw ORMException for unrecognized identifier field (same
    behavior as EntityManager#find)


 Comments   
Comment by Doctrine Bot [ 09/May/15 ]

A related Github Pull-Request [GH-1405] was labeled:
https://github.com/doctrine/doctrine2/pull/1405

Comment by Doctrine Bot [ 09/May/15 ]

A related Github Pull-Request [GH-1405] was assigned:
https://github.com/doctrine/doctrine2/pull/1405





[DDC-3730] Embeddable hydrates to object instead of null Created: 08/May/15  Updated: 08/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Paul Cioanca Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Good afternoon,

When hydrating an Embeddable with nullable attributes the result is an instance of the Embeddable class , this is obviously correct and expected behavior.

If all the attributes are null the hydrator will still return an instance of the class with all of its properties null , even if I persist and flush my Entity with the Embeddable being set as null .

For clarification :


class MyEntity
{
    protected $myEmbeddable;

    public function setMyEmbeddable(MyEmbeddable $myEmbeddable = null)
    {
        $this->myEmbeddable = $myEmbeddable;
    }
    [...]
}

$newEntity = new MyEntity();
$newEntity->setMyEmbeddable(null);

$em->persist($newEntity);
$em->flsuh($newEntity);

Calling $newEntity->getMyEmbeddable() will return an instance of the MyEmbeddable object with all of it's attributes set to null .

I expected $newEntity->getMyEmbeddable() to be NULL .

Can someone clarify is this is expected behaviour ? In case it is , how can I achieve what I'm looking for ?

Best regards






[DDC-3728] [GH-1403] Typo in PHPDoc Created: 07/May/15  Updated: 07/May/15  Resolved: 07/May/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: docblock, entitymanager, phpdoc, typo


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1403

Message:



 Comments   
Comment by Doctrine Bot [ 07/May/15 ]

A related Github Pull-Request [GH-1403] was closed:
https://github.com/doctrine/doctrine2/pull/1403





[DDC-3729] [GH-1404] Fix PHPDoc typo Created: 07/May/15  Updated: 07/May/15  Resolved: 07/May/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: 2.5
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: docblock, entitymanager, typo


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1404

Message:

Title says all.



 Comments   
Comment by Doctrine Bot [ 07/May/15 ]

A related Github Pull-Request [GH-1404] was assigned:
https://github.com/doctrine/doctrine2/pull/1404





[DDC-2531] ManyToManyPersister does not take Custom Types into account Created: 26/Jun/13  Updated: 07/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3, 2.4, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: George van Vliet Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 2
Labels: None


 Description   

When two entities, both using a custom type for the "@Id" column, have a "@ManyToMany" (bidirectional) relationship, the ManyToManyPersister does not take into account the custom type of the referenced id columns and therefore does not convert the values using the appropriate "convertToDatabaseValue" function.

The entities themselves are saved propery, but the insertion into the join table always fails.



 Comments   
Comment by Ben Getsug [ 07/May/15 ]

My scenario:

  • EntityA uses a custom type for its @Id column (specifically so I can store UUIDs in a binary column...see DDC-3721)
  • EntityA has a (unidirectional) many-to-many association with EntityB, and the usual ArrayCollection initialization on the property
  • I clear the entire collection by calling ArrayCollection::clear()
  • I call EntityManager::flush()
  • No errors occur, but no rows actually get deleted from the database.

Through debugging, I found that ManyToManyPersister::getDeleteSQL() does not handle custom types like ManyToManyPersister::getDeleteRowSQL() or ManyToManyPersister::removeElement(). So the proper SQL DELETE statement doesn't get executed.

My current workaround is to loop through my collection of EntityB, calling ArrayCollection::removeElement() with each entity. Given the complexity of ManyToManyPersister, I'm a bit leery of attempting a fix and submitting a PR, but at least wanted to document my issue here.





[DDC-3726] [GH-1401] Remove HHVM-nightly builds Created: 05/May/15  Updated: 06/May/15  Resolved: 05/May/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: build-speed, ci, hhvm, hhvm-nightly, travis

Issue Links:
Reference
is referenced by DBAL-1226 [GH-853] Remove HHVM-nightly builds Resolved

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1401

Message:

hhvm-nightly is not available anymore on Travis because HHVM dropped support for Ubuntu Precise, which is still used by Travis.

This avoids creating useless jobs in the matrix which are killed by Travis from the start.



 Comments   
Comment by Doctrine Bot [ 05/May/15 ]

A related Github Pull-Request [GH-1401] was assigned:
https://github.com/doctrine/doctrine2/pull/1401

Comment by Doctrine Bot [ 05/May/15 ]

A related Github Pull-Request [GH-1401] was labeled:
https://github.com/doctrine/doctrine2/pull/1401

Comment by Doctrine Bot [ 05/May/15 ]

A related Github Pull-Request [GH-1401] was merged:
https://github.com/doctrine/doctrine2/pull/1401





[DDC-3220] Association mappings of embedded class not loaded into entity classMetadata Created: 21/Jul/14  Updated: 06/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Anatolie Marinescu Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: embeddables


 Description   

method inlineEmbeddable from Doctrine\ORM\Mapping\ClassMetadataInfo mapped only columns, but relations is omitted






[DDC-3727] [GH-1402] AbstractCommand: use name of helper, do not require alias Created: 05/May/15  Updated: 05/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1402

Message:

Name for the helper is "entityManager", see https://github.com/doctrine/doctrine2/blob/330f88e44ba0e5e6f932a92ae63b64cdd5cdc046/lib/Doctrine/ORM/Tools/Console/Helper/EntityManagerHelper.php#L70

Using "em" forces creating an alias.

Seems like some forgotten name change.






[DDC-3725] [GH-1400] pgsql and mysqli are supported by HHVM Created: 04/May/15  Updated: 04/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1400

Message:






[DDC-3724] Resolve target entity also in discriminator map: does not work with non-alphabetical order Created: 04/May/15  Updated: 04/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Alan Poulain Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Using a discriminator map and interfaces lead to an exception when there are not in alphabetical order.
For example,

/**
 * @ORM\DiscriminatorMap({
 *     "a" = "AEntityInterface",
 *     "b" = "BEntityInterface"
 * })
 */

is working but,

/**
 * @ORM\DiscriminatorMap({
 *     "b" = "BEntityInterface",
 *     "a" = "AEntityInterface"
 * })
 */

lead to:

[Doctrine\Common\Persistence\Mapping\MappingException]
Class 'BEntityInterface' does not exist






[DDC-3719] Criteria won't work on non-owning side of many to many collection Created: 29/Apr/15  Updated: 03/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: Git Master
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Logan Bailey Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 1
Labels: many-to-many, orm

Issue Links:
Reference
is referenced by DDC-3723 [GH-1399] Fix for DDC-3719. Open

 Description   

I received the following error when trying to call matching on a ManyToMany relationship from the non-owning side.

ErrorException in ManyToManyPersister.php line 234: Undefined index: relationToSourceKeyColumns

ManyToManyPersister::loadCriteria relies on the relationToSourceKeyColumns data from the mapping data. This value is set in ClassMetadataInfo::_validateAndCompleteManyToManyMapping, but it's only set on the owning side of the relationship.






[DDC-3723] [GH-1399] Fix for DDC-3719. Created: 03/May/15  Updated: 03/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Reference
relates to DDC-3719 Criteria won't work on non-owning sid... Open

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1399

Message:

Switch to relationToTargetKeyColumns when matching non-owning side with Criteria. Fixes DDC-3719.






[DDC-3722] XmlExporter driver ignore entityListeners Created: 03/May/15  Updated: 03/May/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Fedir Zinchuk Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: entityListeners, export, orm


 Description   

<entity-listeners> missed in XML export result, when export the entity mapping with entityListeners

And after quick look in the code, seems other drivers also ignore it






[DDC-3721] [GH-1398] When using a custom data type, SchemaTool does not pass column length field mapping to relation join columns Created: 29/Apr/15  Updated: 30/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.4, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1398

Message:

We have a custom data type for storing UUIDs in a BINARY column in MySQL:

class UuidType extends Type
{
    const UUID = 'uuid';


    /**
     * @inheritdoc
     */
    public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
    {
        return $platform->getBinaryTypeDeclarationSQL($fieldDeclaration);
    }


    /**
     * @inheritdoc
     */
    public function getName()
    {
        return self::UUID;
    }


    /**
     * @inheritdoc
     */
    public function convertToPhpValue($value, AbstractPlatform $platform)
    {
        if ($value !== null) {
            return strtoupper(bin2hex($value));
        }
    }


    /**
     * @inheritdoc
     */
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        if ($value !== null) {
            // If the app put any dashes in, we strip them, just in case
            return hex2bin(str_replace('-', '',$value));
        }
    }

    
    /**
     * @inheritdoc
     */
    public function requiresSQLCommentHint(AbstractPlatform $platform)
    {
        return true;
    }
    

    /**
     * Generate a UUID that is optimized for MySQL's InnoDB engine
     * Based on UUID1, but transposed for more optimal inserts and sized for binary(16) column
     *
     * @return string MySQL-optimized UUID that works well with UUID column type
     */
    public static function generateUuid()
    {
        $uuid = Uuid::uuid1()->toString();

        $uuidFormattedForMySQL = self::transposeUuid($uuid);

        return $uuidFormattedForMySQL;
    }


    /**
     * Optimize format of UUID for storing as binary in MySQL
     *
     * @param $uuid
     *
     * @return string
     *
     * @see http://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
     */
    public static function transposeUuid($uuid)
    {
        /*
         * orig UUID1: 13341cb5-c1f8-11e4-91e7-080027880ca6
         * transpose:  11e4-c1f8-13341cb5-91e7-080027880ca6
         * format:     11E4C1F813341CB591E7080027880CA6  <-- this is what can be ideally stored as binary in MySQL
         */
        $uuidOptimizedOrderForMySQL = substr($uuid, 14, 4) . substr($uuid, 9, 4) . substr($uuid, 0, 8) . substr(
                $uuid,
                19,
                17
            );
        $uuidFormattedForMySQL = strtoupper(str_replace('-', '', $uuidOptimizedOrderForMySQL));

        return $uuidFormattedForMySQL;
    }

...and the following related (example) entities:

/**
 * @Entity
 */
class Thing 
{
    /**
     * @Id
     * @var string UUID
     * @Column(type="uuid", length=16)
     * @GeneratedValue(strategy="CUSTOM")
     * @CustomIdGenerator(class="Fisdap\Doctrine\Extensions\IdGenerator\UuidGenerator")
     */
    protected $id;

   /**
     * @OneToOne(targetEntity="OtherThing", mappedBy="thing")
     */
    protected $otherThing;
}

/**
 * @Entity
 */
class OtherThing 
{
        /**
	 * @Id
	 * @Column(type="integer")
	 * @GeneratedValue
	 */
	protected $id;

       /**
	 * @OneToOne(targetEntity="Thing", inversedBy="otherThing")
	 */
	protected $thing;
}

In our case, since SchemaTool::gatherRelationJoinColumns() doesn't copy $fieldMapping['length'] to $columnOptions['length'] for non-string / custom data types, the resulting CREATE TABLE SQL for the OtherThing entity will have a column definition for its association with Thing as thing_id BINARY(0). Of course, MySQL/InnoDB will be unable to create the index for a column with zero length, and multiple exceptions are thrown.

I believe the fix here is to simply check whether $fieldMapping['length'] is set, regardless of the value of $fieldMapping['type']. For good measure, I did the same for $fieldMapping['scale'] and $fieldMapping['precision'].






[DDC-3720] Doctrine - Invalid column name 'sclr0' Created: 29/Apr/15  Updated: 29/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: None
Fix Version/s: 2.5.1
Security Level: All

Type: Task Priority: Major
Reporter: Belita Colares Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: querybuilder


 Description   

My query doesn't work when i use ->setMaxResult with orderBy SUM.

My dataBase is MSSQL SERVER 2008 R2

$query = $entity->createQueryBuilder('t')
->select('SUM(t.price) AS test')
->setMaxResults(10)
>orderBy('test', 'ASC')>getQuery()->getResult();

when i use only
'->select('t.price AS test') ->setMaxResults(10) ->orderBy('test', 'ASC');' doesn't work too

Invalid column name 'sclr0'.
but when i comment this method setMaxResult() my query works fine.

Please help-me, I sorry my english.






[DDC-3718] Inifinite schema diff when using decimal with options unsigned Created: 29/Apr/15  Updated: 29/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Khang Minh Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: mysql, orm, schematool
Environment:

Php 5.6.7 (cli)
MariaDB 10.0.17
Symfony 2.6.1



 Description   

When using a mapping similar to:

        field_name:
            type: decimal
            scale: 2
            options:
                unsigned: true

I keep getting this when issuing app/console doctrine:schema:update --dump-sql (symfony console):

ALTER TABLE table_name CHANGE field_name field_name NUMERIC(10, 2) NOT NULL;

could be related to: http://www.doctrine-project.org/jira/browse/DC-752






[DDC-3717] [GH-1397] Add Expr::concat support for multiple arguments Created: 28/Apr/15  Updated: 28/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1397

Message:

DQL CONCAT function support variable number of arguments (2+) since version `2.4.0`.

The `Expr` class, on the other hand, is still limited to 2 arguments, and require multiple call to achive a similar result (see [this SO question](http://stackoverflow.com/questions/22169324/concat-three-or-more-fields-in-doctrine/29913780)). I've improved `Expr` implementation to support variable number of arguments in a backward compatible way.

Please, consider backporting to `2.4` branch if you plan to release other versions, since `2.5` introduce many features and may not be possible to easily upgrade. I may be wrong, though.






[DDC-3716] [GH-1396] [Documentation] Initializing embeddables doc Created: 27/Apr/15  Updated: 27/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1396

Message:






[DDC-3697] WHERE conditions can get moved into JOIN conditions with JOINed Inheritance and non-association-JOINs Created: 17/Apr/15  Updated: 27/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Malte Wunsch Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: dql, orm


 Description   

With the following entities:

/**
 * @ORM\Entity()
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="discriminaor", type="integer")
 * @ORM\DiscriminatorMap({"1" = "GeneralEntity", "2" = "SpecializedEntity"})
 */
class GeneralEntity {
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    protected $id;
}

/**
 * @ORM\Entity()
 */
class SpecializedEntity extends GeneralEntity {
}

you can create a DQL query (note we're JOINing freely here without traversing a defined association) like

SELECT g1.id
FROM GeneralEntity g1
JOIN GeneralEntity g2
WHERE g2.id = 1

This gets converted to the following SQL:

SELECT g0_.id AS id0
FROM GeneralEntity g0_
LEFT JOIN SpecializedEntity s1_ ON g0_.id = s1_.id
INNER JOIN GeneralEntity g2_
LEFT JOIN SpecializedEntity s3_ ON g2_.id = s3_.id AND (g2_.id = 1)

As you can see, the condition in the WHERE part (g2.id = 1) is no longer in a WHERE clause by it's own, but got moved to the LEFT JOIN of the table inheritance. In this simple special case it probably makes no difference, but in general it does and leads to wrong results.



 Comments   
Comment by Matthias Pigulla [ 27/Apr/15 ]

Here's my attempt at fixing it: https://github.com/doctrine/doctrine2/pull/1395.

Depending on what the WHERE condition looks like, instead of just selecting a small fraction of rows from the root table you may end up selecting all rows plus a mostly useless LEFT JOIN result.





[DDC-3715] [GH-1395] Fix for DDC-3697 Created: 26/Apr/15  Updated: 26/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1395

Message:

Also fix Lexer::match() so it does not accept T_WHERE when T_WITH is supposed to be matched. (DDC-3701)






[DDC-3714] [GH-1394] Fix result cache setting query caching Created: 24/Apr/15  Updated: 24/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1394

Message:

Hello!

This PR fixes the issue with result caching option when query caching is on.

Reproduce is pretty easy. Call same query twice: first time with `Query::useResultCache(true)`, second time with `Query::useResultCache(false)`. If query cache is on - `useResultCache()` setting will be cached along with query itself.

Use case is when you want to keep query cache always on but want sometimes to bypass result cache (e.g. you're sure that underlying data was updated).

P.S. Is it possible to backport fix to 2.4? I can provide another PR for it

Alex






[DDC-3713] [GH-1393] Composite key id used in nullable relations Created: 24/Apr/15  Updated: 24/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1393

Message:

This provides a fix, when you're using a composite primary key, and using part of the composite key as a join column, that will make sure you don't overwrite the composite id key.

Also the fix to Unit of Work needed to consider if part of a composite key was null, it should not try to map the entity.






[DDC-3712] [GH-1392] transactional() wrapper corrupts return values Created: 23/Apr/15  Updated: 23/Apr/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: entitymanager, transactional


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1392

Message:

The EntityManager::transactional() method has undocumented behavior, which unexpectedly rewrites all `false`-ish return values into `true` before passing them on:

    $result = $this->_em->transactional(function (){
        return array();
    }
    assert(is_array($result)); // Fails

I think there's a very strong case to be made that this is undesirable, *however* it's been in existence for a few years now (since DDC-1125) and it's very likely at least a few users have code that relies on the undocumented behavior.

This PR represents the most direct fix, but as a practical matter we may want to improve the documentation instead. If that is the decision, I'd be happy to create a separate PR for documentation changes.






[DDC-3711] Error on manyToMany with composite primary key Created: 23/Apr/15  Updated: 23/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.5
Fix Version/s: 2.4.7
Security Level: All

Type: Bug Priority: Major
Reporter: Marc Pantel Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None
Environment:

symfony 2.6



 Description   

Hi,
I hope that I report in the right place.
I have an issue when I try to create an manyToMany association with an entity with a composite primary key.
The problem is that only one of the two key are create on the association table.

I also have manyToOne association that works fine.

Here are the mapping

Commune.orm.yml

AppDemo\ZoneBundle\Entity\Commune:
    type: entity
    table: ref_commune
    id:
        codeInsee:
            type: string
            nullable: false
            length: 5
            fixed: true
            column: commune_code_insee
        codePostal:
            type: string
            nullable: false
            length: 5
            fixed: true
            column: commune_code_postal
    fields:
        nom:
            type: string
            nullable: false
            length: 100
            fixed: false
            column: commune_nom
    manyToMany:
        zones:
            targetEntity: Zone
            joinTable:
                name: lnk_zone_commune
                joinColumns:
                    commune_code_insee:
                        referencedColumnName: commune_code_insee
                    commune_code_postal:
                        referencedColumnName: commune_code_postal
                inverseJoinColumns:
                    zone_id:
                        referencedColumnName: zone_idx

Zone.orm.yml

AppDemo\ZoneBundle\Entity\Zone:
    type: entity
    repositoryClass: AppDemo\ZoneBundle\Repository\ZoneRepository
    table: ref_zone
    id:
        idx:
            type: integer
            nullable: false
            unsigned: false
            comment: ''
            id: true
            column: zone_idx
            generator:
                strategy: IDENTITY
    fields:
        libelle:
            type: string
            nullable: false
            length: 30
            options:
                default: ''
                comment: 'Libelle de la Zone'


 Comments   
Comment by Marco Pivetta [ 23/Apr/15 ]

What if you simply leave out the joinColumns mappings? Check what comes out of the metadata there, then compare it to your metadata (dump it)

Comment by Marc Pantel [ 23/Apr/15 ]

When I remove the JoinsColumns mapping, I get an error:

Column name `id` referenced for relation from AppBundle\Entity\Commune towards AppBundle\Entity\Zone does not exist.

How do I dump the metadata?





[DDC-3710] Relations inside of embedded objects do not work Created: 23/Apr/15  Updated: 23/Apr/15  Resolved: 23/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Kore Nordmann Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: embeddables, orm

Attachments: File ValueObjectsWithRelationTest.php    

 Description   

If an embeddable has a relation to another object this is neither stored nor fetched.

Find attached a test case showing and reproducing the problem with a Many-To-One relation inside an embeddable.



 Comments   
Comment by Marco Pivetta [ 23/Apr/15 ]

A value object can't have an object reference to an entity by design, as checking its value would then be impossible from the outside (because a VO can't reference a non-VO)





[DDC-3709] [GH-1391] [DDC-3693] Issue with notify change tracking policy Created: 22/Apr/15  Updated: 22/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1391

Message:






[DDC-3700] orderBy stopped working after upgrading to 2.5v (Column not found error) Created: 19/Apr/15  Updated: 22/Apr/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Khurshid Yalgashev Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orderBy
Environment:

ubuntu 14.04


Attachments: JPEG File sl_notification.jpg    

 Description   

Hi,
I have this very simple method in my repository class which fetches a list as query builder object:

public function fetchListAsQueryBuilder(User $user, $receiverType, $limit, $offset)
{
    $queryBuilder = $this->getEntityManager()->createQueryBuilder();
    $query = $queryBuilder
        ->select(['no'])
        ->from('SLCoreBundle:Notification', 'no')
        ->where('no.receiver = :user')
        ->andWhere('no.receiverType = :receiverType')
        ->orderBy('no.createdAt', 'DESC')
        ->setParameters([
            'user' => $user,
            'receiverType' => $receiverType,
        ])
        ->setMaxResults($limit)
        ->setFirstResult($offset)
    ;

    return $query;
}

After upgrading to v2.5 it stopped working and is giving this error:

An exception occurred while executing 'SELECT DISTINCT id_6 FROM (SELECT s0_.receiver_type AS receiver_type_0, s0_.importance AS importance_1, s0_.seen AS seen_2, s0_.deleted AS deleted_3, s0_.created_at AS created_at_4, s0_.updated_at AS updated_at_5, s0_.id AS id_6, s0_.reason AS reason_7 FROM sl_notification s0_ WHERE s0_.receiver_id = ? AND s0_.receiver_type = ?) dctrn_result ORDER BY s0_.created_at DESC LIMIT 25 OFFSET 0' with params [2, 1]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 's0_.created_at' in 'order clause'

My entity has been configured like this:

Mapped superclass AbstractMessage:

abstract class AbstractMessage
{
    use CreatedUpdatedAtTrait;

    // here go properties, setters and getter

Notification class:

class Notification extends AbstractMessage
{
    // here go properties, setters and getters

And CreateUpdatedAtTrait:

trait CreatedUpdatedAtTrait
{
    /**
     * @var \DateTime
     */
    private $createdAt;

    /**
     * @var \DateTime
     */
    private $updatedAt;

    // Here go setters and getters
}

Schema (AbstractMessage) :

<mapped-superclass name="SL\CoreBundle\Entity\AbstractMessage">

    ... 

    <field name="createdAt" column="created_at" type="datetime">
        <gedmo:timestampable on="create" />
    </field>

    <field name="updatedAt" column="updated_at" type="datetime">
        <gedmo:timestampable on="update" />
    </field>

</mapped-superclass>

I'dont understand what causes this error, my others entities work well with this trait, and also my other queries with orderBy method and mappedsuperclass classes work without any error. And also very interesting part is if I remove orderBy my method is working and I am able to get the createdAt value ($object->getCreatedAt()).

PS// Reference: http://stackoverflow.com/questions/29715104/error-with-orderby-column-not-found






[DDC-3708] Doctrine SQL filters and lazy loading causing EntityNotFoundException Created: 22/Apr/15  Updated: 22/Apr/15

Status: Reopened
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: 2.4
Fix Version/s: None
Security Level: All

Type: Documentation Priority: Minor
Reporter: Pavle Predic Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When using a global SQL filter, lazy loading ManyToOne relations may lead to an EntityNotFoundException. You will always get a proxy object for the relation, but as soon as you try to access any property, doctrine will attempt to load the entity from DB, get zero results because the global filter has been applied (assuming that the filter affects the entity in question) and throw an EntityNotFoundException.

What is the recommended way of dealing with this issue globally? The use case is a CMS with a soft-delete feature. A global sql filter filters out entities with a deleted flag. One solution would be to write a custom ProxyFactory that doesn't throw the EntityNotFoundException or to write a custom ProxyGenerator that puts the initializer call in a try/catch block and returns null if an EntityNotFoundException is thrown.

This issue can be resolved by using "fetch EAGER" on ManyToOne relations, but this can lead to performance issues due to the large number of DB queries. How can this problem be solved while still using the lazy loading mechanism?



 Comments   
Comment by Marco Pivetta [ 22/Apr/15 ]

This sort of issue simply occurs when enabling SQL filters after any loading has already happened.

We can't fix this, you are supposed to call Doctrine\ORM\EntityManagerInterface#clear() right after enabling or disabling any filter.

Comment by Pavle Predic [ 22/Apr/15 ]

Filter is enabled from the start. I'm not sure if I managed to explain the issue properly, so let's use an example. Say we have the following entities:

Person (id, name, image_id, deleted)
Image (id, file_name, deleted)

Image is defined as a ManyToOne relation in Person.

Now let's say we have a global SQL filter that filters out all entities where deleted = 1.
Say we have the following data:
Person table:

1, "Jimi", 1, 0

Image table:

1, "jimi.jpg", 1

Now I load the person:

$person = $personRepository->find(1);

If I now access the related Image entity, I will get the instance of Proxy class:

$image = $person->getImage(); //no errors here, doctrine assumes that the relation exists, but doesn't attempt to load it from DB

When I try to get a specific Image attribute, I get an EntityNotFoundException:

$imagePath = $image->getFileName(); //throws an EntityNotFoundException

Obviously, I could use a try/catch block here, but I need a global solution. Most of the time, I'm accessing such relations in a twig template, which is not the best place to deal with exceptions.

Comment by Marco Pivetta [ 22/Apr/15 ]

Reopened: I obviously misunderstood the problem.

I don't think there is a doctrine-side solution to it.

Comment by Pavle Predic [ 22/Apr/15 ]

So definitely not possible to extend ProxyFactory or ProxyGenerator?

Or can this be made into a feature request where a specific config option would force the Proxy to return null instead of throwing an EntityNotFoundException?

Comment by Marco Pivetta [ 22/Apr/15 ]

Since it is an SQL-level filter, it would have to act at SQL level.

One possible solution is to always do joins on filtered associations, and then fetch either NULL or the identifier for those associations.





[DDC-3707] Getting Started contains a broken link Created: 21/Apr/15  Updated: 21/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: 2.x
Fix Version/s: None

Type: Documentation Priority: Minor
Reporter: Chris Smith Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: 404, documentation


 Description   

The reference to Zend DB is broken in the getting started documentation.



 Comments   
Comment by Chris Smith [ 21/Apr/15 ]

I think it should point to here: http://framework.zend.com/manual/1.12/en/zend.db.table.html





[DDC-3706] DQL parsing fail when using COUNT with "Simple Derived Identity" primary key Created: 21/Apr/15  Updated: 21/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: Git Master, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Dmitry Korotovsky Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: bidirectional, count, onetoone, parser
Environment:

Mac osx Maverick
PHP 5.5.13
Nginx 1.6.0
Mysql 5.6.19


Attachments: File DDC3331Test.php    

 Description   

There is the regression https://github.com/doctrine/doctrine2/commit/097840dc935e1cfbc93fc673be077a8fe67e8e52

commit 097840dc935e1cfbc93fc673be077a8fe67e8e52
Author: Marco Pivetta <ocramius@gmail.com>
Date: Wed Aug 27 01:56:11 2014 +0200

Allowing expression in `COUNT()` DQL aggregation functions

:040000 040000 5d5f12583a38f54e5966b1cb65dfe487d932a728 982b2c8642e311730b48c6e5d6e6740c97e3bd5c M lib

On Doctrine 2.5.0 FOSElasticaBundle doesn't work completely

$ php app/console fos:elastica:populate --env=test
Resetting users
Refreshing users

[Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col 13 near 'a) FROM F\Q\C\N\Entity\UserProfile': Error: Invalid PathExpression. Must be a StateFieldPathExpression.

[Doctrine\ORM\Query\QueryException]
SELECT COUNT(a) FROM F\Q\C\N\Entity\UserProfile a






[DDC-3705] Order by With Equals is not supported Created: 20/Apr/15  Updated: 20/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Alexey Kosov Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: dql


 Description   

Related to this issue: http://www.doctrine-project.org/jira/browse/DDC-2204
Solution proposed by Benjamin Eberlei doesn't work so the issue it still unresolved.

SELECT
e.status = 1 AS HIDDEN orderField
FROM
Entity e
ORDER BY
orderField DESC

Doctrine\ORM\Query\QueryException
\vendor\doctrine\orm\lib\Doctrine\ORM\Query\QueryException.php:52
[Syntax Error] line 0, col 47: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '='






[DDC-2204] Order by With Equals is not supported Created: 17/Dec/12  Updated: 20/Apr/15  Resolved: 22/Dec/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Ilya Biryukov Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql
Environment:

SQL construct tested on postgres 9.0, mysql 5.5, and sqlite 3.


Attachments: File Language.sql    

 Description   

The sample query (I want to bring a specific item to the top of the list).
mysql> select * from Language order by name='English' desc, name asc limit 5;
------------+

id name

------------+

82 English
73 Albanian
74 Arabic
75 Armenian
76 Bengali

------------+
5 rows in set (0.00 sec)

In theory, the code below should generate the same query.
$repository->createQueryBuilder('p')
->addOrderBy("p.name='english'", 'desc')
->addOrderBy('p.name', 'asc');

In practice, an exception is thrown.
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 67: Error: Expected end of string, got '=' (uncaught exception) at /vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 44

Attached, SQL dump for the table & data



 Comments   
Comment by Benjamin Eberlei [ 22/Dec/12 ]

Its supported by including the condition in the SELECT clause, aliasing it, then using it. You might need to use "AS HIDDEN name" to prevent it from appearing in the result

Comment by Alexey Kosov [ 20/Apr/15 ]

It does not actually work.

http://stackoverflow.com/questions/25761989/doctrine-select-statement-using-equals-not-accepted





[DDC-3704] [GH-1390] Document the ChainCache class Created: 20/Apr/15  Updated: 20/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1390

Message:

I was thisclose to writing a ChainCache class myself, and only avoided it by actually looking in the source. There's no mention of ChainCache on Google, probably because there's no docs for it. ChainCache is a bit different from other drivers in that it's something implementers will want to use in their own code in place of an ArrayCache or static array. However, I also added a link to the cache drivers given there's quite a few that aren't mentioned in the docs.






[DDC-3703] [GH-1389] Fix Lexer::match() so it does not accept T_WHERE when T_WITH is supposed to be matched Created: 19/Apr/15  Updated: 19/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1389

Message:

http://www.doctrine-project.org/jira/browse/DDC-3701



 Comments   
Comment by Matthias Pigulla [ 19/Apr/15 ]

This is the PR for DDC-3701. Please close or mark as duplicate of DDC-3701, whatever your workflow is.





[DDC-3702] [GH-1388] Fix Lexer::match() so it does not accept T_WHERE when T_WITH is supposed to be matched Created: 19/Apr/15  Updated: 19/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1388

Message:

See http://www.doctrine-project.org/jira/browse/DDC-3701.



 Comments   
Comment by Doctrine Bot [ 19/Apr/15 ]

A related Github Pull-Request [GH-1388] was closed:
https://github.com/doctrine/doctrine2/pull/1388

Comment by Matthias Pigulla [ 19/Apr/15 ]

Please disregard / close.





[DDC-3701] Questions regarding Parser::match and "identifier" EBNF Created: 19/Apr/15  Updated: 19/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Matthias Pigulla Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: None


 Description   

I am currently investigating a problem where I am suspecting the DQL parser to wrongly transform a DQL statement to SQL. While I haven't yet found the exact reason (will open a new case for it), I have come across the following in the Parser::match() method:

   if ($lookaheadType !== $token && $token !== Lexer::T_IDENTIFIER && $lookaheadType <= Lexer::T_IDENTIFIER) {
      $this->syntaxError($this->lexer->getLiteral($token));
   }

The if-condition was changed a while ago in order to allow DQL terms like WHERE to appear as identifiers.

I think that the condition is wrong as it will only fail (create the syntax error) when the actual token does not match the expected type, we're not expecting an "identifier" and the next token is something special like punctuation that could not serve as an identifier.

So, for example when we're match()ing a T_WITH, a T_WHERE will be accepted as well. A correct check would probably not solve my actual problem, but it would probably have been spotted much earlier due to syntax errors issued.

IMO this should actually read

if ($lookaheadType !== $token && ($token !== Lexer::T_IDENTIFIER || $lookaheadType <= Lexer::T_IDENTIFIER)) { ... syntax error ... }

That is, fail if the token does not match the expectation; and when the expectation is T_IDENTIFIER, also accept every terminal string that can also be considered an "identifier".

With this change, the tests almost pass. The only problem is when a FROM clause expects an "identifier" and now a fully qualified class name starting with a backslash is no longer accepted.

Unfortunately, I also did not manage to find an exact definition of "identifier" somewhere in the EBNF. Lexer::getType() considers everything that starts with a character or underscore an identifier, but that does not match FQCNs.

As there seems to be no special token for backslashes, I tried allowing the backslash as a starting character for identifiers as well (in the Lexer), and it seems to work (all non-skipped tests pass).

What do you think about it? Is that something we should fix and does my change make sense?






[DDC-3696] flushing traversable objects Created: 17/Apr/15  Updated: 18/Apr/15

Status: Awaiting Feedback
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5, 2.5.1
Fix Version/s: None
Security Level: All

Type: New Feature Priority: Major
Reporter: mw Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orm, unitofwork


 Description   

Hi,

https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L331

it would be easier if you could the method "flush" pass a traversable object. I've implement this behavior in my decorated entity manager. In my opinion this should be an official supported behavior.

The new code should be inside of Orm\UnitOfWork::commit($entity = null) and looks like the following code:

// Compute changes done since last commit.
if( $entity instanceof \Traversable ) {
	$entity = iterator_to_array( $entity );
}

By the way, the foreach part can be simplified to one line. This can be made possible by array_walk.
You can use:

} elseif (is_array($entity)) {
	array_walk($entity, array($this, 'computeSingleEntityChangeSet'));
}

Now, the new code in one piece:

// Compute changes done since last commit.
if( $entity instanceof \Traversable ) {
	$entity = iterator_to_array( $entity );
}

if ($entity === null) {
	$this->computeChangeSets();
} elseif (is_object($entity)) {
	$this->computeSingleEntityChangeSet($entity);
} elseif (is_array($entity)) {
	array_walk($entity, array($this, 'computeSingleEntityChangeSet'));
}

Thanks in advance.



 Comments   
Comment by Marco Pivetta [ 17/Apr/15 ]

Two things:

1) we are more inclined to remove the parameter from flush(), as it was exploited for purposes it wasn't designed for.
2) what happens if you persist an entity that is a traversable?

Comment by mw [ 17/Apr/15 ]

1.Is that really planned? I guess this is a helpful feature and makes not a difference if you flush a small collection of entities before you flush the remaining entities without the parameter.

2. The object will be treated as entity, because it's an object. This will throw an "Doctrine\ORM\Mapping\MappingException" exception with following message:

Class "SplObjectStorage" is not a valid entity or mapped super class.
Exception-Class: Doctrine\ORM\Mapping\MappingException 
Exception-Code: 0 
Exception-File: Composer/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php 
Exception-Line: 346

This simple senseless code shows you what you can do to test this behavior.

$em = Doctrine_Factory::getEntityManager();
$em->persist($entity);
$x = new SplObjectStorage();
$x->attach($entity);
$em->flush($x);
Comment by Marco Pivetta [ 17/Apr/15 ]

You can implement the Traversable interface (as iterator or iteratoraggregate) on any entity.

As for "planned", it obviously won't happen in 2.x.

We are mainly interested in finding better ways to speed up flush() operations rather than delegating transactional boundaries knowledge to the user.

Anyway, so far, flush($entities) has been more of a source of bugs rather than an actual useful API.

Comment by mw [ 18/Apr/15 ]

The Traversable interface serves to detect whether a class is traversable using foreach. The flush parameter surrenders this parameter one-to-one to $this->unitOfWork->commit($entity).
What I want to do is to hand over an traversable object to the method EntityManager::flush with a collection of entities instead of an single entity object. It's also possible to pass a collection of entities as array. But it's not possible to pass a collection of entities as an object, because when passing an object UnitOfWork::commit assumes that it's an entity. To implement the Traversable interface on any entity will not help and is not the same intention. Because an Traversable object it means, that is a collection of entities like an array.

In my opinion there are not objections that speak against it to support traversable object (SplObjectStorage, ArrayIterator, ArrayObject).

There are two ways to do that.

The first option would be:

// Compute changes done since last commit.
if( $entity instanceof \Traversable ) {
	$entity = iterator_to_array( $entity );
}

if ($entity === null) {
	$this->computeChangeSets();
} elseif (is_object($entity)) {
	$this->computeSingleEntityChangeSet($entity);
} elseif (is_array($entity)) {
	array_walk($entity, array($this, 'computeSingleEntityChangeSet'));
}

The second option would be:

// Compute changes done since last commit.
if ($entity === null) {
	$this->computeChangeSets();
} elseif (is_array($entity) || $entity instanceof \Traversable) {
	foreach ($entity as $object) {
		$this->computeSingleEntityChangeSet($object);
	}
} elseif (is_object($entity)) {
	$this->computeSingleEntityChangeSet($entity);
}

By the way: the SplObjectStorage object has the benefit that every entity is present only once.





[DDC-3699] [GH-1387] Fix skipping properties if they are listed after a not loaded relation. Created: 17/Apr/15  Updated: 18/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1387

Message:

This issue fixes an issue that occurs when merging entites, when the entity that is being merged has some other properties after a association type field.

Fixes the following scenario :
Your entity extends a parent entity and when it is merged by the entity manager first its fields are computed, this is done correctly bby `ReflectionPropertiesGetter::getProperties()`, but in the `mergeEntityStateIntoManagedCopy` method the iteration is stopped when it gets to a field that is a relationship and it is Proxy and was not loaded yet.
The order in which the fields are computed is : current class properties and then the parent properties, so if the current class has a lazy loaded relationship then the properties of the parent are not merged.

So the fix doesn't stop the iteration it just skips the current property that is not loaded yet and goes to the next property.



 Comments   
Comment by Doctrine Bot [ 18/Apr/15 ]

A related Github Pull-Request [GH-1387] was labeled:
https://github.com/doctrine/doctrine2/pull/1387





[DDC-3682] [GH-1379] Added missing 'new' keyword for logger instantiation Created: 09/Apr/15  Updated: 18/Apr/15  Resolved: 18/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation, Second Level Cache
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Steve Müller
Resolution: Fixed Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1379

Message:



 Comments   
Comment by Doctrine Bot [ 18/Apr/15 ]

A related Github Pull-Request [GH-1379] was merged:
https://github.com/doctrine/doctrine2/pull/1379





[DDC-3694] [GH-1384] cs Created: 17/Apr/15  Updated: 18/Apr/15  Resolved: 18/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Improvement Priority: Trivial
Reporter: Doctrine Bot Assignee: Steve Müller
Resolution: Fixed Votes: 0
Labels: code-style, coding-standards, cs


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1384

Message:



 Comments   
Comment by Doctrine Bot [ 18/Apr/15 ]

A related Github Pull-Request [GH-1384] was merged:
https://github.com/doctrine/doctrine2/pull/1384





[DDC-3695] [GH-1385] duplicated param in phpdoc Created: 17/Apr/15  Updated: 18/Apr/15  Resolved: 18/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Steve Müller
Resolution: Fixed Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1385

Message:



 Comments   
Comment by Doctrine Bot [ 18/Apr/15 ]

A related Github Pull-Request [GH-1385] was merged:
https://github.com/doctrine/doctrine2/pull/1385





[DDC-3698] [GH-1386] PersisterException: missing license added Created: 17/Apr/15  Updated: 18/Apr/15  Resolved: 18/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Steve Müller
Resolution: Fixed Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1386

Message:



 Comments   
Comment by Doctrine Bot [ 18/Apr/15 ]

A related Github Pull-Request [GH-1386] was merged:
https://github.com/doctrine/doctrine2/pull/1386





[DDC-3691] Filtering by 'date' column does not return enough values on SQLite Created: 14/Apr/15  Updated: 17/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

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

Windows 8.1 x64
PHP 5.6.2
date.timezone => Europe/Berlin


Attachments: Zip Archive sandbox.zip    

 Description   

When using a column of type 'date' in a where clause, filtering fails and does not return entries which clearly should match.

I have implemented a small proof of concept on the Doctrine sandbox. You can find it by checking out my branch at https://github.com/XitasoChris/doctrine2/tree/date_filter_bug and then run the tools/sandbox/index.php . Alternatively, I have zipped the sandbox folder and attached it to this bug report.

I don't know whether this affects other database systems as well. I only tested it on SQLite.



 Comments   
Comment by Marco Pivetta [ 14/Apr/15 ]

Linking the diff: https://github.com/doctrine/doctrine2/compare/master...XitasoChris:date_filter_bug

Should be a test case, XitasoChris - can you convert it?

Comment by XitasoChris [ 14/Apr/15 ]

@Marco: I will try, though I have never done that on the doctrine project before.

Comment by XitasoChris [ 14/Apr/15 ]

Test case created: https://github.com/doctrine/doctrine2/pull/1383

Comment by XitasoChris [ 17/Apr/15 ]

After some more debugging: The problem is that the type of the parameter is inferred as "datetime", leading Doctrine to format the value as "2015-03-01 00:00:00". However, SQLite needs the value formatted as "2015-03-01" to find a match.

A workaround is to tell Doctrine to format the parameter as a date [$queryBuilder->setParameter("date", $date, "date")] and then the test case works fine.

My question now is: is this behavior expected? If so, then the bug report is probably invalid.





[DDC-3552] Code generation throws exceptions when embeddables are used Created: 30/Jan/15  Updated: 17/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Vladislav Veselinov Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 1
Labels: None


 Description   

I've created a gist showing the code you can use to reproduce the issue
https://gist.github.com/v3labs/d02244c99a87444be709

I've also included the composer.json file.

When I run php app/console doctrine:generate:entities AppBundle -v, I get the following exception:

[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Trying to get property of non-object

Exception trace:
() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:3251
Symfony\Component\Debug\ErrorHandler->handleError() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:3251
Doctrine\ORM\Mapping\ClassMetadataInfo->inlineEmbeddable() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:201
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:225
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:115
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:201
Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getAllMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:164
Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getMetadataForNamespace() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:54
Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getBundleMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Command/GenerateEntitiesDoctrineCommand.php:96
Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:253
Symfony\Component\Console\Command\Command->run() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
Symfony\Component\Console\Application->doRunCommand() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /Users/vladislav/Sites/doctrine2.5_tests/app/console:27

If I add columnPreffix to the @Embed annotation the exception is different:

[Symfony\Component\Debug\Exception\ContextErrorException]
Catchable Fatal Error: Argument 1 passed to Doctrine\ORM\Mapping\ReflectionEmbeddedProperty::__construct() must be an instance of ReflectionP
roperty, null given, called in /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php on
line 952 and defined

Exception trace:
() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php:61
Symfony\Component\Debug\ErrorHandler->handleError() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ReflectionEmbeddedProperty.php:61
Doctrine\ORM\Mapping\ReflectionEmbeddedProperty->__construct() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:952
Doctrine\ORM\Mapping\ClassMetadataInfo->wakeupReflection() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:721
Doctrine\ORM\Mapping\ClassMetadataFactory->wakeupReflection() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:343
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:225
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:115
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:201
Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getAllMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:164
Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getMetadataForNamespace() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Mapping/DisconnectedMetadataFactory.php:54
Doctrine\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory->getBundleMetadata() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/doctrine/doctrine-bundle/Command/GenerateEntitiesDoctrineCommand.php:96
Doctrine\Bundle\DoctrineBundle\Command\GenerateEntitiesDoctrineCommand->execute() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:253
Symfony\Component\Console\Command\Command->run() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:882
Symfony\Component\Console\Application->doRunCommand() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/vladislav/Sites/doctrine2.5_tests/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /Users/vladislav/Sites/doctrine2.5_tests/app/console:27

doctrine:generate:entities [--path="..."] [--no-backup] name

I don't think it's a Symfony specific issue. I tried using the built-in CLI tool and got the same results.



 Comments   
Comment by Marco Pivetta [ 30/Jan/15 ]

Yeah, this can't really work with code-gen, because embeddables require reflection to be initialized in order to operate, whereas the codegen cli-tools operate with a DisconnectedMetadataFactory, which skips reflection on purpose (it assumes that the class does not exist, therefore it does not start up reflection).

I think it's a can't fix for now.

Comment by Vladislav Veselinov [ 30/Jan/15 ]

Sorry for the formatting. I had never used jira before.

Comment by Marco Pivetta [ 30/Jan/15 ]

Vladislav Veselinov fixed the formatting, no big deal

Comment by Vladislav Veselinov [ 30/Jan/15 ]

Btw:

Changing line 947 in ClassMetadataInfo to:

if (isset($mapping['declaredField']) && $parentReflFields[$mapping['declaredField']]) {

seems to bypass the problem and the generation runs fine, but I don't know if it breaks something else. Doesn't seem like it but ... I'm not sure

Comment by Vladislav Veselinov [ 30/Jan/15 ]

Just figured out with it won't work in all cases. I'll keep digging. Thanks for the feedback!

Comment by Konstantinos Christofilos [ 17/Apr/15 ]

Hi,
I was encountered the same issue with embeddables, but it seems to work fine if you define production environment in command:

php app/console doctrine:generate:entities AppBundle --env=prod




[DDC-2795] the queryBuider Expr\Join class has a ON type but unsupported by the parser Created: 14/Nov/13  Updated: 16/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Documentation, DQL
Affects Version/s: 2.4.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 2
Labels: documentation, dql, querybuilder,


 Description   

The Doctrine\ORM\Query\Expr\Join class has 2 cosntants for the condition types: WITH and ON.

None of them are documented. The only place where WITH appear is the EBNF, which is outdated in the doc as it does not show arbitrary joins (added in 2.3) but only association joins.

and when looking at the EBNF in the code, I find 2 different ones (none of them matching the one given in the doc):

  • in Doctrine\ORM\query\Parser::Join:
Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN"
         (JoinAssociationDeclaration | RangeVariableDeclaration)
         ["WITH" ConditionalExpression]

This is matching the implementation and ON is not supported.

  • in Doctrine\ORM\Query\AST\Join:
Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" JoinAssociationPathExpression
         ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression]

This one is missing 2 features also missing in the doc (INDEX BY for associations, and arbitrary joins) and adds the support of ON which is not implemented.

What is the reason to have this ON constant in the query builder ? It is confusing to get a DQL parse exception when using it if it is there.

On a side note, what is the canonical source for the EBNF ? There is 2 different locations in the code (the phpdoc of parser methods and the phpdoc of AST nodes created by the parser), plus the doc. Shouldn't we try to limit the duplication and have a way to check the consistency of the doc ?



 Comments   
Comment by Matthias Pigulla [ 16/Apr/15 ]

Seems http://www.doctrine-project.org/jira/browse/DDC-135 deals with the initial feature addition of WITH. ON was not implemented at that time at least.





[DDC-3633] Schema creation problem on PostgreSQL Created: 22/Mar/15  Updated: 16/Apr/15  Resolved: 16/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Dmitry Korotovsky Assignee: Steve Müller
Resolution: Invalid Votes: 0
Labels: schematool


 Description   

Schema tool can't create correct schema on empty database in PostgreSQL:

$ php app/console doctrine:schema:create --env=test
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...

[Doctrine\ORM\Tools\ToolsException]
Schema-Tool failed with Error 'An exception occurred while executing 'CREATE SCHEMA public':
SQLSTATE[42P06]: Duplicate schema: 7 ERROR: schema "public" already exists' while executing DDL: CREATE SCHEMA public






[DDC-3331] DQL parsing fail when using COUNT with "Simple Derived Identity" primary key Created: 29/Sep/14  Updated: 16/Apr/15  Resolved: 19/Oct/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: Git Master, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Mickael Zhu Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: bidirectional, count, onetoone, parser
Environment:

Mac osx Maverick
PHP 5.5.13
Nginx 1.6.0
Mysql 5.6.19


Attachments: File DDC3331Test.php    

 Description   
Member.php

namespace DoctrineOrmTest\Assets\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="member")
 */
class Member
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer");
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string", nullable=true)
     */
    protected $name;

    /**
     * @var Student
     *
     * @ORM\OneToOne(targetEntity="DoctrineOrmTest\Assets\Entity\Student", mappedBy="member")
     */
    protected $student;

}

Student.php

namespace DoctrineOrmTest\Assets\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="student")
 */
class Student
{
    /**
     * @var Member
     *
     * @ORM\Id
     * @ORM\OneToOne(targetEntity="DoctrineOrmTest\Assets\Entity\Member")
     * @ORM\JoinColumn(name="id", referencedColumnName="id", nullable=false)
     */
    private $member;
}

When I use a oneToOne relation as primary key, the following dql request fail :

SELECT COUNT(a) FROM DoctrineOrmTest\Assets\Entity\Student a

I have the following message :

[Semantical Error] line 0, col 13 near 'a) FROM DoctrineOrmTest\Assets\Entity\Student': Error: Invalid PathExpression. Must be a StateFieldPathExpression

I can fix it with this workaround

SELECT COUNT(a.member) FROM DoctrineOrmTest\Assets\Entity\Student a

But it mess with one of my auto-generation script.



 Comments   
Comment by Marco Pivetta [ 19/Oct/14 ]

You can just COUNT(a.id) here. I don't really see what the problem is.

If you look at the EBNF at http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#ebnf, your current DQL is indeed invalid.

Comment by Marco Pivetta [ 19/Oct/14 ]

To clarify:

AggregateExpression ::= ("AVG" | "MAX" | "MIN" | "SUM" | "COUNT") "(" ["DISTINCT"] SimpleArithmeticExpression ")"

A SimpleArithmeticExpression boils down to a set of ArithmeticPrimary, which is:

ArithmeticPrimary          ::= SingleValuedPathExpression | Literal | "(" SimpleArithmeticExpression ")"

And therefore does not support an entity alias, but only either a Literal (constant value, like a number or a string) or a SingleValuedPathExpression, which is indeed a field of your entity.

Comment by Dmitry Korotovsky [ 16/Apr/15 ]

There is the regression https://github.com/doctrine/doctrine2/commit/097840dc935e1cfbc93fc673be077a8fe67e8e52

commit 097840dc935e1cfbc93fc673be077a8fe67e8e52
Author: Marco Pivetta <ocramius@gmail.com>
Date: Wed Aug 27 01:56:11 2014 +0200

Allowing expression in `COUNT()` DQL aggregation functions

:040000 040000 5d5f12583a38f54e5966b1cb65dfe487d932a728 982b2c8642e311730b48c6e5d6e6740c97e3bd5c M lib

On Doctrine 2.5.0 FOSElasticaBundle doesn't work completely

$ php app/console fos:elastica:populate --env=test
Resetting users
Refreshing users

[Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col 13 near 'a) FROM F\Q\C\N\Entity\UserProfile': Error: Invalid PathExpression. Must be a StateFieldPathExpression.

[Doctrine\ORM\Query\QueryException]
SELECT COUNT(a) FROM F\Q\C\N\Entity\UserProfile a





[DDC-3693] Notify change tracking policy breaks in the face of individual entity flushes Created: 15/Apr/15  Updated: 15/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.2, 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Michael Nielsen Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 2
Labels: None


 Description   

The notify change tracking policy breaks, if other entities are individually flushed between change and flush on a given notify-based entity.

The culprit seems to be that UnitOfWork.commit() resets its scheduledForSynchronization and entityChangeSets arrays (name(s) has changed since 2.2.2) - even when the commit is for a single entity, and the arrays hold other scheduled entities/changes.

An example:

use \net\jay\test\A;

$em = \Doctrine2::getEntityManager();

# persist and flush two instances of A
$a1 = new A(1, 'x');
$a2 = new A(2, 'y');
$em->persist($a1);
$em->persist($a2);
$em->flush();

# change both, but flush $a2 first, then do a general flush
$a1->setName('xx');
$a2->setName('yy');
$em->flush($a2);
$em->flush();

# $a1 entity should be changed, but isn't
$em->clear();
$a1 = $em->getRepository('net\jay\test\A')->find(1);
echo $a1->getName(); # = 'x' (should be 'xx')
namespace net\jay\test;

/**
 * @Entity
 * @ChangeTrackingPolicy("NOTIFY")
 */
class A implements \Doctrine\Common\NotifyPropertyChanged
{
	/** @Id @Column(type="integer") */
	private $id;
	
	/** @Column(length=100) */
	private $name;
	
	private $_changeListeners;
	
	public function __construct($id, $name)
	{
		$this->id = $id;
		$this->name = $name;
	}
	
	public function addPropertyChangedListener(\Doctrine\Common\PropertyChangedListener $listener)
	{
		$this->_changeListeners[] = $listener;
	}
	
	private function _onPropertyChanged($propName, $oldValue, $newValue)
	{
		if ($this->_changeListeners)
		{
			foreach ($this->_changeListeners as $listener)
			{
				$listener->propertyChanged($this, $propName, $oldValue, $newValue);
			}
		}
	}
	
	public function getID()
	{
		return $this->id;
	}
	
	public function getName()
	{
		return $this->name;
	}
	
	public function setName($name)
	{
		$this->_onPropertyChanged('name', $this->name, $name);
		$this->name = $name;
	}
}





[DDC-3690] PersistentCollection uses private property Created: 14/Apr/15  Updated: 15/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Lazy Loading, ORM
Affects Version/s: 2.5
Fix Version/s: 2.5.1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Roel Assignee: Marco Pivetta
Resolution: Unresolved Votes: 0
Labels: collection, persistent-collection, release


 Description   

1. PersistentCollection in Doctrine 2.5 makes uses of the $initialized property defined in the AbstractLazyCollection of doctrine\collection (https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/PersistentCollection.php#L113)
2. Doctrine 2.5 depends on version ~1.2 of doctrine\collection that marks the $initialized property as private https://github.com/doctrine/collections/blob/v1.2/lib/Doctrine/Common/Collections/AbstractLazyCollection.php
3. Hence writing to the initialized variable fails. And thus code related to initialization fails.

A fix is already applied to doctrine\orm https://github.com/doctrine/collections/commit/e2eef4629349fd847c8e080b8f729ab33e81e10f but is not tagged. Possible fix would be to release a new version of doctrine\collection as 1.2.1.



 Comments   
Comment by Roel [ 14/Apr/15 ]

Due to this several tests fail in our code-base.

Comment by Marco Pivetta [ 14/Apr/15 ]

This is a bug caused by the fact that ORM 2.5 should depend on Collections 1.3.0 - I'll look into it ASAP.

Comment by Marco Pivetta [ 15/Apr/15 ]

Collections 1.3.0 was released, but I'll keep this open until ORM 2.5.1 is out.





[DDC-3687] Entities part of a hierarchy seem not to inherit SLC configuration from 'root' Entity Created: 13/Apr/15  Updated: 15/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Second Level Cache
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Documentation Priority: Minor
Reporter: Menno Holtkamp Assignee: Fabio B. Silva
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Reference
relates to DDC-3689 [GH-1382] Patch second level cache as... Resolved

 Description   

When using the Second Level Cache on associations, the documentation states that "the target entity must also be marked as cacheable"

It seems that when this targetEntity is an (possibly abstract) 'root' Entity of an Entity hierarchy, all Entities of that hierarchy need to be marked as cacheable. I would expect that all Entities that are part of the Entity hierarchy, also inherit this cache configuration metadata of the root Entity...

Is this intended behavior?

For example, this does NOT work:

Entity
 - cacheable X-to-many association, targetEntity: RootEntity

RootEntity, SINGLE_TABLE (marked as cacheable)
 - SubEntity1
 - SubEntityN

The generated error:

Array
(
    [type] => 1
    [message] => Call to a member function resolveAssociationEntries() on a non-object
    [file] => /srv/www/code/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php
    [line] => 92
)

For example, this does DOES work

Entity
 - cacheable X-to-many association, targetEntity: RootEntity

RootEntity, SINGLE_TABLE 
 - SubEntity1 (marked as cacheable)
 - SubEntityN (marked as cacheable)


 Comments   
Comment by Fabio B. Silva [ 13/Apr/15 ]

Hi Menno Holtkamp All subclasses should already Inherit the cache configuration .

Can please attach your entities/mapping ?

Comment by Menno Holtkamp [ 13/Apr/15 ]

Mm, you are right, the cache configuration seems to be inherited. General idea of my Mapping is at the end of this comment.

The error occurs after the cache has been filled (2nd request). The following CollectionCacheEntry is used to lookup the EntityEntries:

identifiers => Array ( [0] => Doctrine\ORM\Cache\EntityCacheKey Object ( [identifier] => Array ( [id] => 357 )
entityClass => Project\Domain\Entity\Cms\Page\SectionAbstract
hash => project.domain.entity.cms.page.sectionabstract_357

This results in a $entityEntries collection with one entry, (which is empty!) as retrieved from cache at:
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php#L84

array(1) {
  [0] =>
  NULL
}

Having a look at the actual content of the SLC cache shows that the entry exists, so the lookup goes wrong. It seems 'DefaultRegion::getMultiple()' contains a bug:

https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php#L122

$returnableItems[$index] = $items[$key];

Should be

$returnableItems[$index] = $items[$index];

Since the $items array uses the same keys as the $keysToRetrieve array, filled at https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php#L106

My mapping (pseudo-code)

/**
 * @Entity
 * @Cache
 */
class Page
{
	/**
	 * @OneToMany
	 * @Cache
	 */
	private $translations;
}

/**
 * @Entity
 * @Cache
 */
class Translation
{
	/**
	 * @ManyToOne
	 */
	private $page;
	
	/**
	 * @OneToMany
	 * @Cache
	 */
	private $sections;
}

/**
 * @Entity
 * @Cache
 */
abstract class SectionAbstract
{
	/**
	 * @ManyToOne
	 */
	private $pageTranslation;
}

/**
 * @Entity
 */
class SectionFaq extends SectionAbstract
{

	/**
	 * @var string
	 */
	private $answer;
	
	/**
	 * @var string
	 */
	private $question;
}

/**
 * @Entity
 */
class SectionText extends SectionAbstract
{
	/**
	 * @var string
	 */
	private $content;
}
Comment by Fabio B. Silva [ 13/Apr/15 ]

Yes, it looks like a bug on DefaultRegion::getMultiple()
Can you try to write a failing test case or/and maybe send a PR ?

Comment by Menno Holtkamp [ 13/Apr/15 ]

Mm, will try to find some time this week. Not very experienced in writing test cases though...

Comment by Fabio B. Silva [ 13/Apr/15 ]

Cool,
Take a look at : SecondLevelCacheTest and let me know if you need help..

Comment by Menno Holtkamp [ 13/Apr/15 ]

Ok, challenge accepted, got a test case running in this branch, I used:

php ./vendor/bin/phpunit -v --exclude-group performance,non-cacheable,locking_functional --filter DefaultRegionTest

It seems the way DefaultRegion::getMultiple() works is overcomplicated? Maybe just return the $items array as an end-result?

Comment by Fabio B. Silva [ 13/Apr/15 ]

If you want to refactory it some how, that will be great..
DefaultRegion::getMultiple tries to check if all keys are found in the cache, and then maps it back to the original key
If any of then are missing it will return null which will trigger a new database query to reload the entries and repopulate the cache.

Overall you branch seems good, Can you send a PR please ?

Comment by Menno Holtkamp [ 14/Apr/15 ]

Ok, I gave it a shot at https://github.com/doctrine/doctrine2/pull/1382, AFAIK the index of the resulting array can just be numeric, right?

Comment by Doctrine Bot [ 14/Apr/15 ]

A related Github Pull-Request [GH-1382] was labeled:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 14/Apr/15 ]

A related Github Pull-Request [GH-1382] was assigned:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 14/Apr/15 ]

A related Github Pull-Request [GH-1382] was merged:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 15/Apr/15 ]

A related Github Pull-Request [GH-1382] was unassigned:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 15/Apr/15 ]

A related Github Pull-Request [GH-1382] was assigned:
https://github.com/doctrine/doctrine2/pull/1382





[DDC-3689] [GH-1382] Patch second level cache association hydration Created: 14/Apr/15  Updated: 15/Apr/15  Resolved: 14/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Second Level Cache
Affects Version/s: 2.5
Fix Version/s: 2.5.1, 2.6.0
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: cache, orm

Issue Links:
Reference
is referenced by DDC-3687 Entities part of a hierarchy seem not... Open

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1382

Message:

Fixed incorrect use of keys in DefaultRegion::getMultiple() and simplified overall mechanism



 Comments   
Comment by Doctrine Bot [ 14/Apr/15 ]

A related Github Pull-Request [GH-1382] was labeled:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 14/Apr/15 ]

A related Github Pull-Request [GH-1382] was assigned:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 14/Apr/15 ]

A related Github Pull-Request [GH-1382] was merged:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Guilherme Blanco [ 14/Apr/15 ]

Master: https://github.com/doctrine/doctrine2/commit/5f1861835535c5bd90cf69f5a24f65488975a073
2.5: https://github.com/doctrine/doctrine2/commit/3e6c6af8456a1b2a1ecd5c868be6f792bc857828

Comment by Doctrine Bot [ 15/Apr/15 ]

A related Github Pull-Request [GH-1382] was unassigned:
https://github.com/doctrine/doctrine2/pull/1382

Comment by Doctrine Bot [ 15/Apr/15 ]

A related Github Pull-Request [GH-1382] was assigned:
https://github.com/doctrine/doctrine2/pull/1382





[DDC-3692] [GH-1383] DDC-3691 add test case Created: 14/Apr/15  Updated: 14/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1383

Message:

Test case for DDC-3691






[DDC-2381] Pagination query can be simplified when simple joins are applied Created: 31/Mar/13  Updated: 14/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3, 2.4
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Sergey Gerdel Assignee: Marco Pivetta
Resolution: Unresolved Votes: 3
Labels: paginator

Attachments: HTML File EXPLAIN.htmL     HTML File EXPLAIN1.html     HTML File EXPLAIN2.html     HTML File EXPLAIN3.htm     HTML File EXPLAIN4.htm    

 Description   

Hi.
In mysql db table i have > 200,000 items.
I use native doctrine pagination for paging the items list.
But generated query that gets ids for items list in paging works more then 150 sec on my workstation

SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, m0_.title AS title1, m0_.text AS text2, m0_.price AS price3, m0_.originalPrice AS originalPrice4, m0_.condition_type AS condition_type5, m0_.image_1 AS image_16, m0_.image_2 AS image_27, m0_.image_3 AS image_38, m0_.image_4 AS image_49, m0_.image_5 AS image_510, m0_.video AS video11, m0_.contact_email AS contact_email12, m0_.contact_name AS contact_name13, m0_.contact_phone AS contact_phone14, m0_.contact_type AS contact_type15, m0_.published AS published16, m0_.type AS type17, m0_.status AS status18, m0_.highlight AS highlight19, m0_.urgent AS urgent20, m0_.topads AS topads21, m0_.period AS period22, m0_.hits AS hits23, m0_.ip AS ip24, m0_.created_at AS created_at25, m0_.updated_at AS updated_at26 FROM milla_message m0_ INNER JOIN milla_currency m1_ ON m0_.currency_id = m1_.id INNER JOIN milla_category m2_ ON m0_.category_id = m2_.id INNER JOIN milla_region m3_ ON m0_.region_id = m3_.id INNER JOIN milla_city m4_ ON m0_.city_id = m4_.id WHERE m0_.status = 1 ORDER BY m0_.published DESC) dctrn_result LIMIT 20 OFFSET 0

source code
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L141

why SELECT DISTINCT %s FROM (%s) dctrn_result ???
why not SELECT DISTINCT m0_.id AS id0 FROM milla_message m0_ WHERE m0_.status = 1 ORDER BY m0_.published DESC LIMIT 20 OFFSET 0



 Comments   
Comment by Marco Pivetta [ 31/Mar/13 ]

Not a blocker

Comment by Marco Pivetta [ 31/Mar/13 ]

What's the result of `EXPLAIN` on a query without the subquery?

Comment by Sergey Gerdel [ 31/Mar/13 ]

explain without the subquery

Comment by Marco Pivetta [ 31/Mar/13 ]

Sergey Gerdel that's not the same query.

Comment by Marco Pivetta [ 31/Mar/13 ]

Sergey Gerdel this is still using

Using index; Using temporary; Using filesort

Check your indexes

Comment by Sergey Gerdel [ 31/Mar/13 ]

Not in the index problem

SELECT DISTINCT id0 FROM (SELECT m0_.id AS id0, m0_.title AS title1, m0_.text AS text2, m0_.price AS price3, m0_.originalPrice AS originalPrice4, m0_.condition_type AS condition_type5, m0_.image_1 AS image_16, m0_.image_2 AS image_27, m0_.image_3 AS image_38, m0_.image_4 AS image_49, m0_.image_5 AS image_510, m0_.video AS video11, m0_.contact_email AS contact_email12, m0_.contact_name AS contact_name13, m0_.contact_phone AS contact_phone14, m0_.contact_type AS contact_type15, m0_.published AS published16, m0_.type AS type17, m0_.status AS status18, m0_.highlight AS highlight19, m0_.urgent AS urgent20, m0_.topads AS topads21, m0_.period AS period22, m0_.hits AS hits23, m0_.ip AS ip24, m0_.created_at AS created_at25, m0_.updated_at AS updated_at26 FROM milla_message m0_ WHERE m0_.status = 1 ORDER BY m0_.published DESC) dctrn_result LIMIT 20 OFFSET 0

Time: 104.614s explain 3

SELECT DISTINCT m0_.id AS id0 FROM milla_message m0_ WHERE m0_.status = 1 ORDER BY m0_.published DESC LIMIT 20 OFFSET 0;

Time: 0.001s explain 4

Comment by Marco Pivetta [ 01/Apr/13 ]

Sergey Gerdel the ORM cannot simplify a complex query that way. There may be a conditional on one of the joined results, or generally usage of one of the joined results.

Things that could be optimized here are:

  • Removal of the `ORDER BY` clause when grouping (check ORM master, I think somebody already did that)
  • Trying to simplify the query by doing some serious hacking on the AST.

The problem I see here is that the chance to spawn random bugs because of the optimization is very high, and you'd have to rewrite `walkSelectStatement`

Comment by Marco Pivetta [ 01/Apr/13 ]

Marking as improvement

Comment by Sergey Gerdel [ 07/Apr/13 ]

Minor?
i have 100 sec for this query.
200k items are selected for temporary table. wtf?

OK. Programmers may be mistaken in parser
expect ORDER BY m0_.published DESC LIMIT 20 OFFSET 0) dctrn_result
Time: 0.001s

reality ORDER BY m0_.published DESC) dctrn_result LIMIT 20 OFFSET 0

Comment by Marco Pivetta [ 07/Apr/13 ]

Sergey Gerdel this problem does not introduce security issues and can be worked around by you while using your own pagination logic. It does not stop you from doing anything, that's why it's minor.

Comment by Sergey Gerdel [ 08/Apr/13 ]

ok)
i have already created my own paginator.
at last
please see how to fix this problem
https://github.com/Sergic/doctrine2/commit/2733c815387273d3bd199a68acb717e0cbc8ccfe

Comment by Tom Pryor [ 11/Oct/13 ]

I've also run into this problem which makes Doctrine's Paginator useless for large datasets. The actual query takes 0.002ms but the SELECT DISTINCT query doctrine executes takes over 30s because MySQL creates a temporary table with 200k+ records.

You don't need to remove the joined tables from the paginator query (I have conditions on the joined tables anyway), this has a negligible impact performance, but rather it is caused by SELECT DISTINCT and ORDER BY which no index configuration can solve. Rather, perhaps a flag could be added to the paginator to indicate my query does not fetch join any has many collections (i.e each row returned will be unique) negating the need for the SELECT DISTINCT. The pagination would only then need to perform the original query with LIMIT and OFFSET applied along with a separate COUNT query on the primary key, both of which are very fast as they'd use the indexes setup for the the original query.

Comment by Christophe Coevoet [ 11/Oct/13 ]

This flag already exists for the select query. See the second argument of the constructor.

For the count query, you should call $paginator->setUseOutputWalkers(false) to make it use a DQL AST walker instead of the SQL Output walker (the AST walker does not support counting on queries using HAVING which is why it is not selected by default)

Comment by Robert (Jamie) Munro [ 29/Nov/13 ]

I think this is more important than "minor", as I've experienced this when upgrading from 2.2. My site became unusably slow.

I can't easily work around it because I am using Symfony bundles that use this, I am not using this directly. None of the workarounds mentioned so far seem to have helped.

Comment by Matthias Pigulla [ 14/Apr/15 ]

http://www.doctrine-project.org/jira/browse/DDC-3646 seems to be related or identical.





[DDC-3646] Do not select unused columns in inner queries of Paginator Created: 31/Mar/15  Updated: 14/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Malte Wunsch Assignee: Steve Müller
Resolution: Unresolved Votes: 1
Labels: paginator
Environment:

In my case MySQL 5.1, other versions or DBMS may optimise that by themselves



 Description   

When a {{Paginator count()}}s, it fires a query like this:

SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id0 FROM (%originalQuery%) dctrn_result) dctrn_table

an getIterator() does something similar for joined collections to get the ids in the first place:

SELECT DISTINCT id0, lastmod11 FROM (%originalQuery%) dctrn_result ORDER BY lastmod11 DESC LIMIT 10 OFFSET 0

My problem is that both the inner queries can be too heavy for a regular temporary table.

At first sight I noticed several LEFT JOIN s that could be stripped from the inner query without changing the result of the outer one. But that might have been a specially easy case, a general optimisation of the JOIN clauses might be harder. I think http://www.doctrine-project.org/jira/browse/DDC-2381 deals with that.

On second thought we noticed some ugly BLOB columns as part of the projection, which unhealthily bloated the temporary table. Ultimately, the BLOBs are needed for the paginated view, but they are neither needed for counting nor for getting the paginated ids.

Hence, I propose to remove unused columns from the projection in the inner queries. "Unused" means not being part of the SELECT or ORDER BY clause in the outer query (and maybe not part of GROUP BY, HAVING... - haven't checked on this yet). The key could be the $innerSql in the LimitSubqueryOutputWalker->walkSelectStatement(), but before investigating further, I'd like to hear from you what you think.



 Comments   
Comment by Marco Pivetta [ 31/Mar/15 ]

Please review https://github.com/doctrine/doctrine2/pull/1353, as it might solve this issue

Comment by Malte Wunsch [ 31/Mar/15 ]

Thanks for your quick reply!

To be honest, I don't fully get the PR. At least it's goals look very different to me. Anyway, in LimitSubqueryOutputWalker the $innerSQL is now being generated in getInnerSQL(). In there, some hiddenAliasResultVariable are set to false (and are later restored) so that the parent SQLWalker can reference selected fields better. This might be a requirement for implementing my idea, but as far as I understand, there are no columns removed from the select clause so far?

Comment by Doctrine Bot [ 31/Mar/15 ]

A related Github Pull-Request [GH-1353] was closed:
https://github.com/doctrine/doctrine2/pull/1353

Comment by Marco Pivetta [ 06/Apr/15 ]

Malte Wunsch the PR is actually related as it affects the selected fields.

Consider checking again against 2.5.0, as we indeed fixed many paginator issues, and this issue needs to be re-validated.

Comment by Malte Wunsch [ 07/Apr/15 ]

Great! I'll be glad to check. It might take some time, as we currently only have PHP 5.3 at our disposal (please don't tell anybody), and Doctrine 2 ORM 2.5.0 requires at least PHP 5.4. Fortunately, this is a very good trigger to put some pressure on the PHP upgrade process. I'll keep my eye on it.

Comment by Malte Wunsch [ 10/Apr/15 ]

Marco Pivetta Unfortunately, Doctrine 2.5 had no effect on my inner original query. It still looks like this:

SELECT 
  COUNT(*) AS dctrn_count 
FROM 
  (
    SELECT 
      DISTINCT id0 
    FROM 
      (
        SELECT 
          [all fields from t0_],
          [all fields from t1_],
          [all fields from t2_],
          [all fields from t3_]
        FROM 
          table1 t0_ 
          LEFT JOINs...
        WHERE 
          ...
        ORDER BY 
          ...
      ) dctrn_result
  ) dctrn_table

Just to be clear, my point is with the most inner query. If I'm correct it is generated in LimitSubqueryOutputWalker->getInnerSql(). In the special case with the query above, one could simplify it by dropping the order clause, removing the left joins and selecting only the id0 field. I have no plan for inner joins and other more complex optimisations, but I guess that removing the unused fields from the select clause might be in reach.

Comment by Matthias Pigulla [ 10/Apr/15 ]

When removing fields from the SELECT clause, we need to keep those that are referenced from GROUP BY or HAVING clauses (when ORDER BY is dropped).

Comment by Matthias Pigulla [ 14/Apr/15 ]

http://www.doctrine-project.org/jira/browse/DDC-2381 seems to be related or identical.





[DDC-2838] Leaky abstraction when applying Criteria to hydrated/non-hydrated PersistentCollection Created: 03/Dec/13  Updated: 14/Apr/15

Status: Reopened
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: brian ridley Assignee: Marco Pivetta
Resolution: Unresolved Votes: 2
Labels: None

Attachments: File DDC2838Test.php    
Issue Links:
Reference
is referenced by DCOM-275 Collections\Expr\ClosureExpressionVis... Open
is referenced by DCOM-249 Criteria are unable to locate getters... Open

 Description   

When applying a Criteria to a PersistentCollection that has been hydrated the field names must be camel case, if the collection has not yet been hydrated the field names must be underscore separated.

The github repo linked here contains a simplified testcase for the matrix of hydrated/non-hydrated entities and camel case/underscore separated fields.

https://github.com/ptlis/DoctrineTestcase



 Comments   
Comment by Marco Pivetta [ 18/Aug/14 ]

We can't check out an entire project just to test a bug.

Please write an actual functional test case that can be integrated into the Doctrine ORM test suite.

Comment by brian ridley [ 20/Aug/14 ]

Hi,

i'm happy to do so - i'll take a look at this over the weekend.

Comment by Simon Paridon [ 12/Dec/14 ]

brian ridley: Any progress on this? This is currently an issue for us as well and hope to get fixed. I could look into converting it to a test for integration with the test suite if you don't have the time... but it might take a while since I have no experience with the requirements that should be met. (Plus, I am not sure how tightly coupled it is with your project)

Comment by Simon Paridon [ 17/Dec/14 ]

Hi Marco Pivetta, brian ridley,

I attached a functional Test that integrates with the test suite. Please let me know if I should issue a PR, and I'll do that this evening.

Comment by Florian Preusner [ 26/Dec/14 ]

+1





[DDC-2780] IS [NOT] NULL conditions with JOINs Created: 06/Nov/13  Updated: 14/Apr/15  Resolved: 30/Mar/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Marek Štípek Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

<?php
When trying to apply a [NOT] NULL condition on LEFT JOINed association. It ends with an error.

"Cannot add having condition on a non result variable."

$queryBuilder
->leftJoin('r.players', 'players', 'WITH', 'players = :player')
->where('players IS NULL');

It was working 3 month ago. But then, this commit broke it.

https://github.com/doctrine/doctrine2/commit/d9c1782a4f6d46f66e9deb2c375830f9192d4482

Or in other words if this is not a bug. How to test if the collection does not contain let's say a user with ID 5 (AND XX OR YY) with DQL/queryBuilder API? IN SQL I would just simply LEFT JOIN it with ON condition and then i would test it for existence using IS NULL in WHERE condition. How to do this using DQL when the pasted example ends with an error?



 Comments   
Comment by Marek Štípek [ 30/Mar/14 ]

OK. players.id IS NULL (but it's uglier)

Comment by Sullivan SENECHAL [ 14/Apr/15 ]

`r.players IS NULL` works too.

But I don't understand why this will be not fixed. I agree, it's uglier.





[DDC-3686] cascade with inheritence objects Created: 12/Apr/15  Updated: 13/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: sky diablo Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

this is just a dummy text, i create a unittest-case to demonstrate the issue. so i need this DDC-Number for...



 Comments   
Comment by sky diablo [ 13/Apr/15 ]

hmmm.. i have create a new unittest with my issue, but no error :| i will add some more tests and give here a sign later...

Comment by sky diablo [ 13/Apr/15 ]

i have create a new unittest in my doctrine2 ORM fork: https://github.com/skydiablo/doctrine2/blob/master/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3686Test.php all works fine, but in my real enviroment, it dosnt, here the effected code:

class Dossier {

    /**
     * @ORM\ManyToOne(targetEntity="Reference", cascade={"all"})
     * @ORM\JoinColumn(name="reference_id", referencedColumnName="id")
     */
    private $reference;
}

class Reference {

    /**
     * @ORM\ManyToOne(targetEntity="Company", cascade={"all"})
     * @ORM\JoinColumn(name="company_id", referencedColumnName="id", nullable=true)
     */
    private $company;
}

/**
 * Class ParticipantObject
 *
 * @ORM\Entity()
 * @ORM\Table(name="company_participant_object")
 * @ORM\InheritanceType(value="JOINED")
 * @ORM\DiscriminatorColumn(name="discriminator", type="string", length=45)
 * @ORM\DiscriminatorMap({
 *      "company" = "Company"
 * })
 */
abstract class ParticipantObject {

}

class Company extends ParticipantObject {

    /**
     * @ORM\ManyToOne(targetEntity="CompanyData", cascade={"all"})
     * @ORM\JoinColumn(name="company_data_id", referencedColumnName="id")
     */
    private $companyData;
}

class CompanyData {

    /**
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
     */
    private $name = '';
}

all classes are annotated with a entity and table declaration. so this entitys should be the same as in my unittest. but in my real enviroment, the "company_id" in the "reference" object will never persist? and i do not know why ??? all other entitys are saved, the new "company" entity is persist ans stored in the database with the "CompanyData" and "ParticipantObject", all works fine... all data available in the database, but the "company_id" in the "reference" object is missing .... ahhhhhhh !!! whats wrong ?





[DDC-3688] Order By column doesn't have number suffix in Paginator Created: 13/Apr/15  Updated: 13/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Thomas Koch Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 1
Labels: None


 Description   
An exception occurred while executing 'SELECT DISTINCT IDuser_16 FROM (SELECT a0_.username AS username_0, a0_.username_canonical AS username_canonical_1, a0_.email AS email_2, a0_.email_canonical AS email_canonical_3, a0_.enabled AS enabled_4, a0_.salt AS salt_5, a0_.password AS password_6, a0_.last_login AS last_login_7, a0_.locked AS locked_8, a0_.expired AS expired_9, a0_.expires_at AS expires_at_10, a0_.confirmation_token AS confirmation_token_11, a0_.password_requested_at AS password_requested_at_12, a0_.roles AS roles_13, a0_.credentials_expired AS credentials_expired_14, a0_.credentials_expire_at AS credentials_expire_at_15, a0_.IDuser AS IDuser_16, a0_.uname AS uname_17, a0_.uprename AS uprename_18, a0_.status AS status_19, a0_.FKIDare AS FKIDare_20, a0_.IDparent AS IDparent_21 FROM aus2_users a0_ WHERE a0_.status IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) dctrn_result ORDER BY a0_.username ASC LIMIT 10 OFFSET 0' with params [1, 2, 5, 6, 8, 9, 10, 11, 12, 13, 14]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a0_.username' in 'order clause'

Stacktrace: 
[1] Doctrine\DBAL\Exception\InvalidFieldNameException: An exception occurred while executing 'SELECT DISTINCT IDuser_16 FROM (SELECT a0_.username AS username_0, a0_.username_canonical AS username_canonical_1, a0_.email AS email_2, a0_.email_canonical AS email_canonical_3, a0_.enabled AS enabled_4, a0_.salt AS salt_5, a0_.password AS password_6, a0_.last_login AS last_login_7, a0_.locked AS locked_8, a0_.expired AS expired_9, a0_.expires_at AS expires_at_10, a0_.confirmation_token AS confirmation_token_11, a0_.password_requested_at AS password_requested_at_12, a0_.roles AS roles_13, a0_.credentials_expired AS credentials_expired_14, a0_.credentials_expire_at AS credentials_expire_at_15, a0_.IDuser AS IDuser_16, a0_.uname AS uname_17, a0_.uprename AS uprename_18, a0_.status AS status_19, a0_.FKIDare AS FKIDare_20, a0_.IDparent AS IDparent_21 FROM aus2_users a0_ WHERE a0_.status IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) dctrn_result ORDER BY a0_.username ASC LIMIT 10 OFFSET 0' with params [1, 2, 5, 6, 8, 9, 10, 11, 12, 13, 14]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a0_.username' in 'order clause'
    at n/a
        in /home/dev/git/comsolit/kurad/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 71

    at Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException('An exception occurred while executing 'SELECT DISTINCT IDuser_16 FROM (SELECT a0_.username AS username_0, a0_.username_canonical AS username_canonical_1, a0_.email AS email_2, a0_.email_canonical AS email_canonical_3, a0_.enabled AS enabled_4, a0_.salt AS salt_5, a0_.password AS password_6, a0_.last_login AS last_login_7, a0_.locked AS locked_8, a0_.expired AS expired_9, a0_.expires_at AS expires_at_10, a0_.confirmation_token AS confirmation_token_11, a0_.password_requested_at AS password_requested_at_12, a0_.roles AS roles_13, a0_.credentials_expired AS credentials_expired_14, a0_.credentials_expire_at AS credentials_expire_at_15, a0_.IDuser AS IDuser_16, a0_.uname AS uname_17, a0_.uprename AS uprename_18, a0_.status AS status_19, a0_.FKIDare AS FKIDare_20, a0_.IDparent AS IDparent_21 FROM aus2_users a0_ WHERE a0_.status IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) dctrn_result ORDER BY a0_.username ASC LIMIT 10 OFFSET 0' with params [1, 2, 5, 6, 8, 9, 10, 11, 12, 13, 14]:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'a0_.username' in 'order clause'', object(PDOException))
        in /home/dev/git/comsolit/kurad/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php line 116

    at Doctrine\DBAL\DBALException::driverExceptionDuringQuery(object(Driver), object(PDOException), 'SELECT DISTINCT IDuser_16 FROM (SELECT a0_.username AS username_0, a0_.username_canonical AS username_canonical_1, a0_.email AS email_2, a0_.email_canonical AS email_canonical_3, a0_.enabled AS enabled_4, a0_.salt AS salt_5, a0_.password AS password_6, a0_.last_login AS last_login_7, a0_.locked AS locked_8, a0_.expired AS expired_9, a0_.expires_at AS expires_at_10, a0_.confirmation_token AS confirmation_token_11, a0_.password_requested_at AS password_requested_at_12, a0_.roles AS roles_13, a0_.credentials_expired AS credentials_expired_14, a0_.credentials_expire_at AS credentials_expire_at_15, a0_.IDuser AS IDuser_16, a0_.uname AS uname_17, a0_.uprename AS uprename_18, a0_.status AS status_19, a0_.FKIDare AS FKIDare_20, a0_.IDparent AS IDparent_21 FROM aus2_users a0_ WHERE a0_.status IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) dctrn_result ORDER BY a0_.username ASC LIMIT 10 OFFSET 0', array('1', '2', '5', '6', '8', '9', '10', '11', '12', '13', '14'))
        in /home/dev/git/comsolit/kurad/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php line 836

    at Doctrine\DBAL\Connection->executeQuery('SELECT DISTINCT IDuser_16 FROM (SELECT a0_.username AS username_0, a0_.username_canonical AS username_canonical_1, a0_.email AS email_2, a0_.email_canonical AS email_canonical_3, a0_.enabled AS enabled_4, a0_.salt AS salt_5, a0_.password AS password_6, a0_.last_login AS last_login_7, a0_.locked AS locked_8, a0_.expired AS expired_9, a0_.expires_at AS expires_at_10, a0_.confirmation_token AS confirmation_token_11, a0_.password_requested_at AS password_requested_at_12, a0_.roles AS roles_13, a0_.credentials_expired AS credentials_expired_14, a0_.credentials_expire_at AS credentials_expire_at_15, a0_.IDuser AS IDuser_16, a0_.uname AS uname_17, a0_.uprename AS uprename_18, a0_.status AS status_19, a0_.FKIDare AS FKIDare_20, a0_.IDparent AS IDparent_21 FROM aus2_users a0_ WHERE a0_.status IN (?)) dctrn_result ORDER BY a0_.username ASC LIMIT 10 OFFSET 0', array(array('1', '2', '5', '6', '8', '9', '10', '11', '12', '13', '14')), array('102'), null)
        in /home/dev/git/comsolit/kurad/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php line 50

    at Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(object(Connection), array(array('1', '2', '5', '6', '8', '9', '10', '11', '12', '13', '14')), array('102'))
        in /home/dev/git/comsolit/kurad/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php line 321

    at Doctrine\ORM\Query->_doExecute()
        in /home/dev/git/comsolit/kurad/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 969

    at Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(null, '3')
        in /home/dev/git/comsolit/kurad/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 924

    at Doctrine\ORM\AbstractQuery->execute(null, '3')
        in /home/dev/git/comsolit/kurad/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php line 751

    at Doctrine\ORM\AbstractQuery->getScalarResult()
        in /home/dev/git/comsolit/kurad/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php line 151

    at Doctrine\ORM\Tools\Pagination\Paginator->getIterator()
        in  line 

    at iterator_to_array(object(Paginator))

I use the doctrine paginator on a normal FosUserBundle user entity. It worked with doctrine-common 2.4.2, -orm 2.4.7 and throws this exception with doctrine 2.5.

While I stepped through the code with xdebug I got this notice once, but I can't reproduce it anymore:

Notice: Undefined property: Doctrine\ORM\Tools\Pagination\LimitSubqueryOutputWalker::$queryComponents in vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php at line 1369

with this stacktrace:

at SqlWalker ->walkSelectExpression (object(SelectExpression)) 
at array_map (array(object(LimitSubqueryOutputWalker), 'walkSelectExpression'), array(object(SelectExpression))) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php at line 699   + 
at SqlWalker ->walkSelectClause (object(SelectClause)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php at line 521   + 
at SqlWalker ->walkSelectStatement (object(SelectStatement)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php at line 492   + 
at LimitSubqueryOutputWalker ->getInnerSQL (object(SelectStatement)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php at line 271   + 
at LimitSubqueryOutputWalker ->walkSelectStatementWithoutRowNumber (object(SelectStatement), false) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php at line 319   + 
at LimitSubqueryOutputWalker ->addMissingItemsFromOrderByToSelect (object(SelectStatement)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php at line 263   + 
at LimitSubqueryOutputWalker ->walkSelectStatementWithoutRowNumber (object(SelectStatement)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php at line 184   + 
at LimitSubqueryOutputWalker ->walkSelectStatement (object(SelectStatement)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php at line 42   + 
at SingleSelectExecutor ->__construct (object(SelectStatement), object(LimitSubqueryOutputWalker)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php at line 277   + 
at SqlWalker ->getExecutor (object(SelectStatement)) 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php at line 390   + 
at Parser ->parse () 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 281   + 
at Query ->_parse () 
in vendor/doctrine/orm/lib/Doctrine/ORM/Query.php at line 293   + 
at Query ->_doExecute () 
in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 969   + 
at AbstractQuery ->executeIgnoreQueryCache (null, '3') 
in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 924   + 
at AbstractQuery ->execute (null, '3') 
in vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php at line 751   + 
at AbstractQuery ->getScalarResult () 
in vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php at line 151   + 
at Paginator ->getIterator () 
at iterator_to_array (object(Paginator)) 
in src/Comsolit/KuradBundle/Util/PaginatorJsonResponse.php at line 76   + 

Maybe this is related to DDC-3434?



 Comments   
Comment by Thomas Koch [ 13/Apr/15 ]

Our user class has a relation to another entity:

     /**
     * @ORM\ManyToOne(targetEntity="Organization", fetch="EAGER")
     * @ORM\JoinColumn(name="id", referencedColumnName="organization_id", nullable=true)
     * @var \Comsolit\EntityOrganization
     */
    private $organization;




[DDC-3684] [GH-1381] Fixes ClassMetadata wakeupReflection with embeddable and StaticReflectio... Created: 11/Apr/15  Updated: 13/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1381

Message:

...nService

When the `StaticReflectionService` is used, then the wakeupReflection will cause an error with embedded properties. This is because the `getAccessibleProperty` method of the `StaticReflectionService` will always return null, so the parentReflFields will only have null values.

I found this problem when I was generating a Symfony form based on an entity with embedded properties.



 Comments   
Comment by Doctrine Bot [ 13/Apr/15 ]

A related Github Pull-Request [GH-1381] was labeled:
https://github.com/doctrine/doctrine2/pull/1381

Comment by Doctrine Bot [ 13/Apr/15 ]

A related Github Pull-Request [GH-1381] was assigned:
https://github.com/doctrine/doctrine2/pull/1381





[DDC-3685] wrong bit check ? Created: 12/Apr/15  Updated: 12/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: sky diablo Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

this is just a hint:

https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/UnitOfWork.php#L716

i think it is a good idea to use a bit save check, like:

if (($assoc['type'] & ClassMetadata::TO_ONE) == ClassMetadata::TO_ONE) {






[DDC-3683] [GH-1380] Fix issue with second-level-cache tests and versioned entities Created: 10/Apr/15  Updated: 10/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Second Level Cache
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: cache, testing, version

Issue Links:
Dependency
is required for DDC-3681 [GH-1378] Feature to force-increment ... Awaiting Feedback

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1380

Message:

I'm not sure why this bug doesn't show normally `master`, but I ran across it with build [3930.1](https://travis-ci.org/doctrine/doctrine2/jobs/57975906), where it complained since `$targetPersister` was not an instance of `CachedPersister`.

The immediate fix seems straightforward, because `DefaultCollectionHydrator` doesn't even accept the second argument.

@FabioBatSilva : Please let me know if you see some better resolution to this, or if it indicates some edge-case in the second-level-cache logic that requires a new test.






[DDC-3481] [GH-1241] [3.0] [POC] lazy-load on a per-property base Created: 09/Jan/15  Updated: 09/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Reference
is referenced by DCOM-282 Use call_user_func_array in proxy cla... Open

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1241

Message:

This is just a proof of concept that I hacked together real quick.

This changes how proxies are generated and lazy-loaded in a very radical way:

  • method calls do not cause lazy-loading
  • lazy-loading is triggered by access to non-transient properties (things that need to be lazy-loaded)
  • access to identifiers or non-mapped properties won't cause lazy-loading

Following BC breaks need to be fixed or discussed before going forward on this idea:

  • [ ] proxies don't implement `Doctrine\Common\Proxy\Proxy` anymore, but `ProxyManager\Proxy\GhostObjectInterface` (BC break, needs fixing, can be easily done with some effort)
  • [ ] `serialize($proxy)` now causes proxy initialization (probably needs fixing, as this is a major BC break)

Pending TODOs:

  • [ ] cloning a proxy is still not fully supported (requires dedicated logic in `__clone`)
  • [ ] this is just a PoC, so the code that writes proxies to disk is not yet in place


 Comments   
Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1241] was labeled:
https://github.com/doctrine/doctrine2/pull/1241

Comment by Doctrine Bot [ 24/Jan/15 ]

A related Github Pull-Request [GH-1241] was labeled:
https://github.com/doctrine/doctrine2/pull/1241





[DDC-3640] Force version increment via mapped property Created: 26/Mar/15  Updated: 09/Apr/15  Resolved: 09/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Darien Hager Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: mapping, orm

Issue Links:
Duplicate
duplicates DDC-3681 [GH-1378] Feature to force-increment ... Awaiting Feedback
Reference
relates to DDC-2864 New type of lock: OPTIMISTIC_FORCE_IN... Open
relates to DDC-1507 State change detection for version in... Open

 Description   

Existing feature:

It is currently possible to use optimist-locking against an entity through a version code or timestamp, which becomes incremented when the entity changes. Unfortunately, there is no way for an entity to signal that its version should be incremented when no (direct) changes have occurred.

Problem:

Sometimes you want to control or gate wide-spread or indirect changes via a particular entity, such as the root of a tree of other mutable entities. This is particularly common in Domain Driven Design.

Proposal:

Create a new configuration option for a PHP property that identifies it as a "version incrementor flag". It is only legal on entities that also have a version-field. This field will always be set to false when an entity is hydrated.

When entities are being checked for changes and flushed, this flag will (if it evaluates to true) force the version-field to update. Note that if the entity has "real changes", it will be saved and the version-field will update regardless. At the end of this process, the field is reset back to false.

This allows the user to write code such as:

Entity example

    /** @Version @Column(type="integer") */
    private $version;

    /** @VersionIncrementFlag */
    $changed = false;

    /** @OneToMany(targetEntity="Child", mappedBy="parent") */
    private $children;    

    public function zeroChildren(){
        foreach($this->children as $child){
            $child->setValue(0);
        }
        $this->changed = true; // Where $changed is the incrementor flag
    }    

Issues with other approaches:

The current workaround of a "junk column" is... suboptimal. It requires a junk data column in the database, and its presence does not easily capture the intent of the user. It also leads to extra database operations, since the junk data has to be saved no matter what.

Adding a specialized method to EntityManager, like with $em->touchVersion($entity); is also problematic, since it means you cannot conveniently trigger the new behavior when deep inside the object-graph.



 Comments   
Comment by Darien Hager [ 26/Mar/15 ]

I'm willing to try implementing this if folks feel it could get included.

Comment by Darien Hager [ 27/Mar/15 ]

I have a proof-of-concept working based off of 2.4.7, you can see a diff here:

https://github.com/doctrine/doctrine2/compare/2.4...DHager:force_version_increment

As of this writing, it can only be configured via XML. Here's a minimal example, for a table that has only two columns, an ID and a version.

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
  <entity name="Example\Foo" table="example">

    <special-properties>
        <special-property name="vflag" type="versionIncFlag"/>
    </special-properties>

    <id name="id" type="integer" column="id"/>

    <field name="version" type="integer" column="version" version="true" nullable="false"/>

  </entity>
</doctrine-mapping>

The new <special-properties> section is intended to refer to PHP object-properties which are not mapped fields, but which still have significance to Doctrine. In PHP-land, it's as simple as:

        $targetId = 1;
        /** @var $em EntityManager */                
        /** @var $foo Foo */
        $foo = $em->find("Example\Foo",$targetId); // Hardcoded ID
        $foo->vflag = true; // TODO make private, use setter
        $em->persist($foo);
        $em->flush();

Afterwards, the "version" column in the DB for the row should be incremented, even though no "real" fields were changed:

UPDATE example SET version = version + 1 WHERE id = ? AND version = ?
Comment by Darien Hager [ 06/Apr/15 ]

Another possibility may be to implement this as a listener with the `onFlush` event, but even then the kind of configuration being done seems like it ought to be stored (and accessed) along with everything else, as opposed to living in its own config or doing a separate pass on the annotations/xml/etc.

Comment by Darien Hager [ 09/Apr/15 ]

Created a slightly different implementation and made a pull-request for visibility. Further comments should probably go to DDC-3681.





[DDC-3680] [GH-1377] Failing test case for broken paginator case Created: 08/Apr/15  Updated: 09/Apr/15  Resolved: 09/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: 2.5.1
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Bill Schaller
Resolution: Fixed Votes: 0
Labels: limitsubqueryoutputwalker, mysql, paginator


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1377

Message:

http://www.doctrine-project.org/jira/browse/DDC-3679



 Comments   
Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1377] was assigned:
https://github.com/doctrine/doctrine2/pull/1377

Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1377] was labeled:
https://github.com/doctrine/doctrine2/pull/1377

Comment by Doctrine Bot [ 09/Apr/15 ]

A related Github Pull-Request [GH-1377] was merged:
https://github.com/doctrine/doctrine2/pull/1377





[DDC-3679] Paginator generates broken SQL when paginating ordered query Created: 08/Apr/15  Updated: 09/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Filip Procházka Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 1
Labels: dql, mysql, orm


 Description   

I have a following DQL

SELECT ra FROM Damejidlo\Recipes\RecipeAuthor ra ORDER BY ra.id ASC

Which generates following SQL

SELECT r0_.id AS id_0, r0_.name AS name_1, r0_.perex AS perex_2, r0_.is_active AS is_active_3, r0_.on_homepage AS on_homepage_4, r0_.content AS content_5, r0_.photo AS photo_6, r0_.link AS link_7 FROM recipes_authors r0_ ORDER BY r0_.id ASC

Now I wanna paginate it

$query = $em->createQuery($dql);
$paginated = new \Doctrine\ORM\Tools\Pagination\Paginator($query, TRUE);

the generated SQL Count query is

SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT r0_.id AS id_0, r0_.name AS name_1, r0_.perex AS perex_2, r0_.is_active AS is_active_3, r0_.on_homepage AS on_homepage_4, r0_.content AS content_5, r0_.photo AS photo_6, r0_.link AS link_7 FROM recipes_authors r0_ ORDER BY r0_.id ASC) dctrn_result) dctrn_table

Next executed query is the query that selects ids for where in

SELECT DISTINCT id_0 FROM (SELECT r0_.id AS id_0, r0_.name AS name_1, r0_.perex AS perex_2, r0_.is_active AS is_active_3, r0_.on_homepage AS on_homepage_4, r0_.content AS content_5, r0_.photo AS photo_6, r0_.link AS link_7 FROM recipes_authors r0_) dctrn_result ORDER BY r0_.id ASC LIMIT 5 OFFSET 0

And there goes my problem

Doctrine\DBAL\Exception\InvalidFieldNameException

An exception occurred while executing '...': SQLSTATE[42S22]: Column not found: 1054 Unknown column 'r0_.id' in 'order clause'

I'm going to investigate more, I just wanned to open an issue for now so you're aware.



 Comments   
Comment by Filip Procházka [ 08/Apr/15 ]
aa80c7d!orm $> bisect start
aa80c7d!orm $> bisect bad
aa80c7d!orm $> bisect good v2.4.7
Bisecting: a merge base must be tested
[29d6da0fa063d55d06117045f3446b2716202d2b] Merge pull request #703 from shulcsm/patch-1
29d6da0!orm $> bisect good
Bisecting: 912 revisions left to test after this (roughly 10 steps)
[a2e0133a94bf235498ee2e805c8ca9a147b7fa24] Adding DDC-3276 test group
a2e0133!orm $> bisect good
Bisecting: 456 revisions left to test after this (roughly 9 steps)
[dde09872df4f442f3a2a4c9ce6053badb8b49012] #1172 - writing a more concise test case about merging detached proxies
dde0987!orm $> bisect good
Bisecting: 233 revisions left to test after this (roughly 8 steps)
[d024193cc0d106d4939bbf698f840ef122602d64] Merge pull request #1272 from Ocramius/hotfix/DDC-2704-merge-inherited-transient-properties
d024193!orm $> bisect good
Bisecting: 116 revisions left to test after this (roughly 7 steps)
[6cf76158a07219529631f7b8fb43c3b92d3552be] Merge pull request #1329 from Wilt/patch-1
6cf7615!orm $> bisect good
Bisecting: 58 revisions left to test after this (roughly 6 steps)
[d1a695b42b54ed7deb2f9461fee7d02d32514c3a] Typo in phpdoc
d1a695b!orm $> bisect good
Bisecting: 28 revisions left to test after this (roughly 5 steps)
[b923c937e2194ae38c88e31cfcea8d06b58603fc] Merge branch 'hotfix/#1352-entity-generator-new-class-metadata-hotfix'
b923c93!orm $> bisect good
Bisecting: 14 revisions left to test after this (roughly 4 steps)
[6c5dbd8d4ca4fd68f0d5b2de467c3d2a59e0173c] #1353 #1347 #1351 - Removing double quotes (confusing)
6c5dbd8!orm $> bisect bad
Bisecting: 6 revisions left to test after this (roughly 3 steps)
[af3f5c5c5a93daf240c2daae4eddf9a0628eeb19] Add test for paginating on a query with a subquery in the where clause
af3f5c5!orm $> bisect good
Bisecting: 3 revisions left to test after this (roughly 2 steps)
[b76107e20f7fa893c2e4945a373ff624ed00c0d2] resolve review comments from @stof
b76107e!orm $> bisect bad
Bisecting: 0 revisions left to test after this (roughly 1 step)
[edcc0fc024e0d33a4f6159c006c0f393386dac3a] Fix paginator when ordering by while selecting entities using joined table inheritance
edcc0fc!orm $> bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[09d28819b520b9219bd6f41e8c6e0f4449a3807b] Fix issue where paginating on a query with a subquery in the where clause crashed
09d2881!orm $> bisect good
edcc0fc024e0d33a4f6159c006c0f393386dac3a is the first bad commit
commit edcc0fc024e0d33a4f6159c006c0f393386dac3a
Author: Bill Schaller <bill@zeroedin.com>
Date:   Mon Mar 30 12:16:50 2015 -0400

    Fix paginator when ordering by while selecting entities using joined table inheritance

:040000 040000 aa2bd1b6cb6dc10ef39c3ea1affe78c75bb2b778 4dc9a0e15f847bfc940096263a639d6f1a4eb618 M      lib
:040000 040000 fa9a72d3eaae021b0015e43bbe64a9cf7eadf46e 7b6821dd22bee36c808e4680a427aa3ec75faad0 M      tests
09d2881!orm $>
Comment by Filip Procházka [ 08/Apr/15 ]

I've narrowed down the problem to this piece of code

lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
+            $fieldMapping = $class->fieldMappings[$columnName];
+            if (isset($fieldMapping['declared']) && $fieldMapping['declared'] !== $class->name) {
+                // Field was declared in a parent class, so we need to get the proper SQL table alias
+                // for the joined parent table.
+                $otherClassMetadata = $this->_em->getClassMetadata($fieldMapping['declared']);
+                $sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
+            }

This breaks the searchPatterns map

Because it thinks it needs to use different table alias for mapped superclass that contains the `id` property.

Comment by Filip Procházka [ 08/Apr/15 ]

I've opened a pullrequest with failing test case https://github.com/doctrine/doctrine2/pull/1377

Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1377] was assigned:
https://github.com/doctrine/doctrine2/pull/1377

Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1377] was labeled:
https://github.com/doctrine/doctrine2/pull/1377

Comment by Doctrine Bot [ 09/Apr/15 ]

A related Github Pull-Request [GH-1377] was merged:
https://github.com/doctrine/doctrine2/pull/1377





[DDC-3647] [GH-1354] [RFC] Added support for OneToMany with orphanRemoval. Created: 01/Apr/15  Updated: 08/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1354

Message:

Replacing entire collection now deletes the replaced collection (scheduled for deletion). No event handling is done as it happens at DBAL level.

Fixes DDC-3644



 Comments   
Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1354] was assigned:
https://github.com/doctrine/doctrine2/pull/1354

Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1354] was labeled:
https://github.com/doctrine/doctrine2/pull/1354

Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1354] was labeled:
https://github.com/doctrine/doctrine2/pull/1354





[DDC-3635] QueryBuilder - INSTANCE OF with parameter not working Created: 24/Mar/15  Updated: 08/Apr/15

Status: Reopened
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Wouter Wiltenburg Assignee: Guilherme Blanco
Resolution: Unresolved Votes: 0
Labels: binding, dql, parameter
Environment:

Zend Framework 2



 Description   

I use single table class inheritance.
When I write my INSTANCE OF clause in my QueryBuilder like this:

    $result = $this->createQueryBuilder('o')
        ->leftJoin('o.child', 'c')
        ->where('c INSTANCE OF :entity_class')
        ->setParameter('entity_class', 'My\Entity\Class')
        ->getQuery()
        ->getResult();

It does not work correctly. The problem seems to lie in the fact that the parameter is bound to the SQL query. So if I change the entity_class to the discriminator column name it works correctly.

So if the discriminator value for My\Entity\Class would be discriminator then this does work:

    $result = $this->createQueryBuilder('o')
        ->leftJoin('o.child', 'c')
        ->where('c INSTANCE OF :entity_class')
        ->setParameter('entity_class', 'discriminator')
        ->getQuery()
        ->getResult();

So the step for getting the discriminator column from the class name is missing and instead the class name is bound to the MySql query directly.



 Comments   
Comment by Guilherme Blanco [ 08/Apr/15 ]

INSTANCE OF expressions expect either their class names or their corresponding class metadata. This means the following examples are valid:

$qb->where('c INSTANCE OF My\Entity\Class');

// or

$qb
    ->where('c INSTANCE OF :param')
    ->setParameter('param', $em->getClassMetadata('My\Entity\Class'))
;

Assigning class name directly does not work.
Closing as invalid.

Comment by Marco Pivetta [ 08/Apr/15 ]

Re-opening. I think this is a documentation issue then, as http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html#id2 says that the InstanceOfParameter accepts also an InputParameter

Comment by Guilherme Blanco [ 08/Apr/15 ]

Marco Pivetta And it does. However, the bound parameter must be a ClassMetadata.





[DDC-3678] [GH-1376] add missing property initialized to PersistentCollection Created: 08/Apr/15  Updated: 08/Apr/15  Resolved: 08/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: collection, initialized, persistent-collection


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1376

Message:

This property is accessed from various methods in PersistentCollection, but not declared prior to __construct()



 Comments   
Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1376] was assigned:
https://github.com/doctrine/doctrine2/pull/1376

Comment by Doctrine Bot [ 08/Apr/15 ]

A related Github Pull-Request [GH-1376] was closed:
https://github.com/doctrine/doctrine2/pull/1376





[DDC-3671] Duplicated unique indexes (@UniqueConstraint annotation) Created: 07/Apr/15  Updated: 08/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Michał Bundyra Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: duplicate, index, schema-tool

Issue Links:
Duplicate
is duplicated by DDC-3677 [GH-1375] DDC-3671 prevent duplicate ... Open

 Description   

In this commit:
https://github.com/doctrine/dbal/commit/fc8beca08600b44e46f7b82998adbcc6d52c31f1
was changed to not checking for if index already exists. After that occur problem with duplicated unique keys (for example migrations try add unique index on the same columns with different index name).

This is an example model:

/**
 * @Entity
 * @Table(name="double_uniq_index_table", uniqueConstraints={
 *   @UniqueConstraint(name="uniq_hash", columns={"hash"})
 * })
 */
class DoubleUniqIndexModel
{
    /** @Id @Column */
    private $id;

    /** @Column(name="hash", type="string", length=8, nullable=false, unique=true) */
    private $hash;
}

and the basic test:

    public function testDoubleUniqIndex()
    {
        $em = $this->_getTestEntityManager();
        $schemaTool = new SchemaTool($em);

        $classes = array(
            $em->getClassMetadata(__NAMESPACE__ . '\\DoubleUniqIndexModel'),
        );

        $schema = $schemaTool->getSchemaFromMetadata($classes);

        $this->assertTrue($schema->hasTable('double_uniq_index_table'));
        $this->assertEquals(2, count($schema->getTable('double_uniq_index_table')->getIndexes()));
    }

(I've added it into: tests/Doctrine/Tests/ORM/Tools/SchemaToolTest.php).

Test failures, because generated schema contains three indexes (primary, and two unique on the same column with different names - one auto generated uniq_* and one provided in annotations - uniq_hash).






[DDC-3677] [GH-1375] DDC-3671 prevent duplicate unique index Created: 08/Apr/15  Updated: 08/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates DDC-3671 Duplicated unique indexes (@UniqueCon... Open

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1375

Message:






[DDC-3676] Entity executing UPDATE on Collection elements with PostLoad callback when cloning Created: 08/Apr/15  Updated: 08/Apr/15  Resolved: 08/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.7
Fix Version/s: None
Security Level: All

Type: Bug Priority: Minor
Reporter: webDEVILopers Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: PostLoad, clone
Environment:

Debian, Symfony2



 Description   

My `Branch` entity has a collection of `Contract`s.
https://gist.github.com/webdevilopers/65716f36ac2249e5e899#file-branch-php

A `Contract` has a PostLoad event which is converting a legacy yaml database field to a readable format.
https://gist.github.com/webdevilopers/65716f36ac2249e5e899#file-contract-php

When cloning a Branch the database executes a single INSERT for the new branch successfully.
It does NOT persist any collection which is the expected behaviour since I guess relations have to be handled inside the __clone method separately.

But after the INSERT the database also fires an UPDATE on each Contract (currently ~3000 related rows in database) updating the column that was converted inside the PostLoad event.

/**
* @ORM\PostLoad
*
* Legacy workaround converting custom fields yaml to aray
*/
public function convertCustomFieldsYamlToArray()
{
    $customFieldsYaml = $this->getCustomFields();
    if (empty($customFieldsYaml)) { return; }
    $customFields = yaml_parse($customFieldsYaml);
    $this->setCustomFields($customFields);
} 

I think calling the PostLoad is correct. But why is there an additional UPDATE called?

$em = $this->getDoctrine()->getManager();
$branch = $em->getRepository('AppBundle:Branch')->find(1);

dump($branch);
echo "Old ID:" . $branch->getId();

$newBranch = clone $branch;
dump($newBranch);

$em->persist($newBranch);
$em->flush();

dump($newBranch);
echo "<br>New Id:" . $newBranch->getId(); 

https://gist.github.com/webdevilopers/65716f36ac2249e5e899#file-branchcontroller-php

Maybe the flush recognizes changes in the original Branch entity and its Contract collection?

When I add a clear to my __clone method I get ~9 instead of ~3000 UPDATE queries:

    /**
     * @see http://doctrine-orm.readthedocs.org/en/latest/cookbook/implementing-wakeup-or-clone.html
     */
    public function __clone() {
        if ($this->id) {
            $this->contracts->clear();
        }
    }

These 9 remaing UPDATE are additionally fired by another callback:

    /**
     * @ORM\PrePersist
     * @ORM\PreUpdate
     *
     * Legacy workaround converting custom fields to yaml format utf8 encoded
     */
    public function convertCustomFieldsArrayToYaml()
    {
        $customFields = $this->getCustomFields();
        $customFieldsYaml = yaml_emit($customFields, YAML_UTF8_ENCODING);
        $this->setCustomFields($customFieldsYaml);
    }

In summary:
At the bottom line the __clone method causes 9 UPDATE queries for Pre* and ~3000 (number of related database rows) for PostLoad.



 Comments   
Comment by Marco Pivetta [ 08/Apr/15 ]

Resolving as invalid: please provide a small reproducible example that is not specific to your codebase.

As it stands, this seems more like a debugging request.

Comment by webDEVILopers [ 08/Apr/15 ]

Sure Marco, I will add some fixtures to my example to make it reproducable if that is enough for debugging?





[DDC-3479] [GH-1240] Include IDs in the exception message to ease debugging Created: 08/Jan/15  Updated: 08/Apr/15  Resolved: 13/Jan/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: exception-message, exceptions, identifier, not-found, proxy

Issue Links:
Duplicate
is duplicated by DDC-3675 Additional informations when throwing... Resolved

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1240

Message:

Include IDs in the exception message of the EntityNotFoundException to ease debugging.



 Comments   
Comment by Doctrine Bot [ 09/Jan/15 ]

A related Github Pull-Request [GH-1240] was assigned:
https://github.com/doctrine/doctrine2/pull/1240

Comment by Doctrine Bot [ 13/Jan/15 ]

A related Github Pull-Request [GH-1240] was closed:
https://github.com/doctrine/doctrine2/pull/1240





[DDC-3675] Additional informations when throwing EntityNotFoundException Created: 08/Apr/15  Updated: 08/Apr/15  Resolved: 08/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Daniel Mecke Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: orm

Issue Links:
Duplicate
duplicates DDC-3479 [GH-1240] Include IDs in the exceptio... Resolved

 Description   

When a EntityNotFoundException is thrown it would be very helpful for debugging to get the informations which entity was not found as well as which identifiers where used for the lookup.



 Comments   
Comment by Daniel Mecke [ 08/Apr/15 ]

Duplicate to DDC-3479

Sorry!





[DDC-3596] Do not allow entity column name "decimal" or escape somehow Created: 02/Mar/15  Updated: 08/Apr/15  Resolved: 08/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, Mapping Drivers, ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Aurimas Niekis Assignee: Guilherme Blanco
Resolution: Invalid Votes: 0
Labels: None


 Description   

Problem is that after creation and schema update of entity with property "decimal" it makes problem to insert and alter that column.

On schema update it uses this SQL to create table:

CREATE TABLE Unit (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, unit VARCHAR(255) NOT NULL, `decimal` SMALLINT NOT NULL, decimal_point VARCHAR(1) NOT NULL, thousands_separator VARCHAR(1) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

When trying to persist entity I get exception

  [Doctrine\DBAL\DBALException]
  An exception occurred while executing 'INSERT INTO Unit (name, unit, decimal, decimal_point, thousands_separator) VALUES (?, ?, ?, ?, ?)' with params ["Cubic meters", "m\u00b3", "2", ".", ","]:
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'deci
  mal, decimal_point, thousands_separator) VALUES ('Cubic meters', 'm³', '2',' at line 1

Or alter table to rename column

  [Doctrine\DBAL\DBALException]
  An exception occurred while executing 'ALTER TABLE Unit CHANGE decimal decimal_numbers SMALLINT NOT NULL':
  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'deci
  mal decimal_numbers SMALLINT NOT NULL' at line 1


 Comments   
Comment by Guilherme Blanco [ 08/Apr/15 ]

You missed to quote your columns to properly escape during column manipulation.
Closing as invalid.

Comment by Marco Pivetta [ 08/Apr/15 ]

Re-opening to remove resolution version





[DDC-3674] Additional informations when closing EntityManager Created: 08/Apr/15  Updated: 08/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Daniel Mecke Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: orm, unitofwork


 Description   

When the EntityManager is closed there is no way to find out why it has been closed afterwards. For example it would be nice if ORMException::entityManagerClosed() could add the information which query caused it to close. That would ease debugging a lot.
Maybe the EntityManager::close() method could get a parameter which stores the query or informations about it in a property next to the EntityManager::closed property?






[DDC-3673] Foreign key ignores options on schema update Created: 07/Apr/15  Updated: 07/Apr/15  Resolved: 07/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5.1, 2.6.0
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Yuri Pimenov Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: mysql, orm
Environment:

"php": ">=5.3.3", "doctrine/orm": "2.6.*@dev" (tried with several older versions with no success), Mysql configuration in attachment.


Attachments: File mysql_variables.csv    

 Description   

To reproduce create 2 tables:

CREATE TABLE `books` (
  `id` INT UNSIGNED NOT NULL,
  `title` VARCHAR(45) NULL,
  PRIMARY KEY (`id`));

CREATE TABLE `authors` (
  `id` INT UNSIGNED NOT NULL,
  `book_id` INT NOT NULL,
  `name` VARCHAR(45) NULL,
  PRIMARY KEY (`id`));

Pay attention that books.id is UNSIGNED and authors.book_id is not UNSIGNED (default). This is my legacy schema, I reverse engineered it to Doctrine entities like so:

Author.php
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="authors")
 * @ORM\Entity
 */
class Author
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", options={"unsigned"=true})
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=45)
     */
    private $name;

    /**
     * @var Book
     *
     * @ORM\ManyToOne(targetEntity="Book")
     * @ORM\JoinColumn(name="book_id", referencedColumnName="id")
     */
    private $book;
}

Book.php
<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="books")
 * @ORM\Entity
 */
class Book
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=45)
     */
    private $title;
}

Please notice

options={"unsigned"=true}

in Book.id definition. Actually it does not have an effect (I guess it must).

Then when I run

$> app/console doctrine:schema:update --dump-sql --force

get the mysql error:

ALTER TABLE authors ADD CONSTRAINT FK_8E0C2A5116A2B381 FOREIGN KEY (book_id) REFERENCES books (id);
CREATE INDEX IDX_8E0C2A5116A2B381 ON authors (book_id);
ALTER TABLE books CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE title title VARCHAR(45) NOT NULL;

Updating database schema...

  [Doctrine\DBAL\Exception\DriverException]
  An exception occurred while executing 'ALTER TABLE authors ADD CONSTRAINT FK_8E0C2A5116A2B381 FOREIGN KEY (book_id) REFERENCES books (id)':
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

  [PDOException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constrain

Than if I manually ALTER Author and then add foreign key constraint it works:

ALTER TABLE `authors` 
CHANGE COLUMN `book_id` `book_id` INT(11) UNSIGNED NULL DEFAULT NULL ;

ALTER TABLE authors ADD CONSTRAINT FK_8E0C2A5116A2B381 FOREIGN KEY (book_id) REFERENCES books (id)

But if I run doctrine:schema:update again it recreates definition with the same error:

ALTER TABLE authors DROP FOREIGN KEY FK_8E0C2A5116A2B381;
ALTER TABLE authors CHANGE book_id book_id INT DEFAULT NULL;
DROP INDEX fk_8e0c2a5116a2b381 ON authors;
CREATE INDEX IDX_8E0C2A5116A2B381 ON authors (book_id);
ALTER TABLE authors ADD CONSTRAINT FK_8E0C2A5116A2B381 FOREIGN KEY (book_id) REFERENCES books (id);
ALTER TABLE books CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE title title VARCHAR(45) NOT NULL;

Updating database schema...

  [Doctrine\DBAL\Exception\DriverException]
  An exception occurred while executing 'ALTER TABLE authors ADD CONSTRAINT FK_8E0C2A5116A2B381 FOREIGN KEY (book_id) REFERENCES books (id)':
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

  [Doctrine\DBAL\Driver\PDOException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

  [PDOException]
  SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint


 Comments   
Comment by Yuri Pimenov [ 07/Apr/15 ]

Just checked test setup one more time. options=

{"unsigned":true}

were defined in wrong Entity.





[DDC-3672] After update to 2.5.0 we need left join to order correctly with pagination Created: 07/Apr/15  Updated: 07/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

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

MySQL 5.6



 Description   

Before update to 2.5.0 I had follow code working:

$qb = $this->_em->createQueryBuilder()->select('customer')->from('Test\Entity\Customer', 'customer');
$qb->addOrderBy('customer.person', 'ASC');
$paginator = new Paginator($query);
var_dump($paginator->getIterator());

As workaround I had to add:

$qb->leftJoin('customer.person', 'person');
// and update orderBy to
$qb->addOrderBy('person.id', 'ASC');


 Comments   
Comment by Marco Pivetta [ 07/Apr/15 ]

Does

ORDER BY IDENTITY(customer.person)

work?

Comment by Guilherme Santos [ 07/Apr/15 ]

Nop, same error..
Sorry, I don't tell you the error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c0_.person_id' in 'order clause'
Comment by Christophe Coevoet [ 07/Apr/15 ]

Marco Pivetta Looks like we are still missing a bunch of functional tests for the pagination

Comment by Marco Pivetta [ 07/Apr/15 ]

Christophe Coevoet yeah, a whole lot of them :-\





[DDC-3652] Problem with joins between entities without associations Created: 02/Apr/15  Updated: 06/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Eunice Valdez Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Reference
relates to DDC-3410 Allow Query Builder to specify the jo... Open

 Description   

I needed to write a DQL query that selects an entity that is not specified in the FROM part. For that I am using joins between entities without associations. But I found a problem. Let me explain it with the following example:

Here the query I wrote

            SELECT l
            FROM Label l
            JOIN l.product_labels pl
            JOIN pl.product p
            JOIN creams.c WITH c.product = p
            WHERE c.type = 'general_cleaners'
            AND l.name = "Eye cleaners"

This is translated to SQL as:

SELECT 
  l0_.id AS id0, 
  l0_.name AS name1, 
FROM 
  label l0_ 
  INNER JOIN product_label p1_ ON l0_.id = p1_.label_id 
  INNER JOIN product p2_ ON p1_.product_id = p2_.id 
  INNER JOIN creams c3_ 
  AND (c3_.product = p2_.id)  <---- this should be in the WHERE part!
WHERE 
  c3_.type = 'general_cleaners'
 AND l0_.name "Eye cleaners"

What happens is that the query gets all the products with the label "Eye cleaners" and the creams having that belong to those products. But it never filters out the products that have no cream association.

To go around the problem I added the condition

AND c.product = p.id

in the WHERE clause in the DQL query

After searching for the issue I found something related but no the same. So i decided to put my findings under your consideration.

Thanks a lot



 Comments   
Comment by Marco Pivetta [ 06/Apr/15 ]
AND (c3_.product = p2_.id)  <---- this should be in the WHERE part!

Why should it go in the WHERE clause? You specified it on a join WITH condition, which in ORM terms translates to an additional ON clause





[DDC-3661] Doctrine\ORM\LazyCriteriaCollection unpredictable count() Created: 04/Apr/15  Updated: 06/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Fedir Zinchuk Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: count, lazy, lazy-criteria-collection, lazy-loading, orm

Issue Links:
Dependency
is required for DDC-3668 [GH-1372] [DDC-3661] Fix count in Doc... Open

 Description   

When criteria has set $maxResults Doctrine\ORM\LazyCriteriaCollection::count() can return different result depend when it was called, before initialize() or after.

When LazyCriteriaCollection not initialized then count() return Total from database,
when LazyCriteriaCollection have been initialized then count() return Total from "collection" that is limited by Criteria::$maxResults.

Example you have 30 items in database and Criteria::$maxResults = 5, then:

$items = $repositiry->matching($criteria);
var_dump($items->count()); // will show 30 items
$items->toArray();
var_dump($items->count()); // will show 5 items

It is very confuse

also I not sure which behaviour is right: it should always return Total from database or Total depend from Criteria::$maxResults



 Comments   
Comment by Marco Pivetta [ 04/Apr/15 ]

This is indeed a bug: consider writing an example test case so that we can work on it.

Comment by Fedir Zinchuk [ 04/Apr/15 ]

I think I found solution, I try make pull request tomorrow

Comment by Fedir Zinchuk [ 05/Apr/15 ]

there it is https://github.com/doctrine/doctrine2/pull/1372

For exaple can take that docs.doctrine-project.org/en/latest/reference/working-with-associations.html#filtering-collections

For example for User entity:
if you have BirthdayUsers in database 100 and run next code:

$repositiry = $em->getRepository('User');
$criteria = Criteria::create()
    ->where(Criteria::expr()->eq("birthday", "1982-02-17"))
    ->orderBy(array("username" => Criteria::ASC))
    ->setFirstResult(0)
    ->setMaxResults(20)
;
$birthdayUsers = $repositiry->matching($criteria);
var_dump($birthdayUsers->count()); // will show 100 items
$birthdayUsers->toArray();
var_dump($birthdayUsers->count()); // will show 20 items
Comment by Doctrine Bot [ 06/Apr/15 ]

A related Github Pull-Request [GH-1372] was labeled:
https://github.com/doctrine/doctrine2/pull/1372





[DDC-3668] [GH-1372] [DDC-3661] Fix count in Doctrine\ORM\LazyCriteriaCollection Created: 05/Apr/15  Updated: 06/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Dependency
depends on DDC-3661 Doctrine\ORM\LazyCriteriaCollection u... Open

 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1372

Message:

Fix Doctrine\ORM\LazyCriteriaCollection::count() when Criteria::$maxResults defined

ps. I have no idea how to write test for it :speak_no_evil:



 Comments   
Comment by Doctrine Bot [ 06/Apr/15 ]

A related Github Pull-Request [GH-1372] was labeled:
https://github.com/doctrine/doctrine2/pull/1372





[DDC-3670] [GH-1374] Fix DDC767Test failing on php7 + pg94 Created: 05/Apr/15  Updated: 06/Apr/15  Resolved: 06/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.5
Fix Version/s: 2.5.1, 2.6.0
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: fragile-test, pgsql, pgsql-9.4, php-7.0, postgresql, tests, testsuite
Environment:

PHP 7.0 + PGSQL 9.4



 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1374

Message:

The failure happens when running the full suite or even just:

```
phpunit tests/Doctrine/Tests/ORM/Functional/Ticket
```

see: https://revive.beccati.com/bamboo/browse/PHP-DOCPG-MAS-164/log

For reference:
```
05-Apr-2015 04:39:42 ...S......................................................... 1342 / 2921 ( 45%)
05-Apr-2015 04:39:43 ........SSS...........................................SS
05-Apr-2015 04:39:43 Fatal error: Argument 1 passed to Doctrine\Tests\Models\CMS\CmsUser::addGroup() must be an instance of Doctrine\Tests\Models\CMS\CmsGroup, null given, called in /home/atlassian/bamboo/xml-data/build-dir/PHP-DOCPG-MAS/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC767Test.php on line 63 and defined in /home/atlassian/bamboo/xml-data/build-dir/PHP-DOCPG-MAS/tests/Doctrine/Tests/Models/CMS/CmsUser.php on line 211
```

I wasn't able to replicate with other PHP versions. On PHP7, running `tests/Doctrine/Tests/ORM/Functional/Ticket` yields 20, 21 and 22 as group IDs, rather than 1, 2, 3. Maybe some cleanup isn't run?

Removing hardocoded IDs seems a sensible thing to do anyway.



 Comments   
Comment by Doctrine Bot [ 06/Apr/15 ]

A related Github Pull-Request [GH-1374] was assigned:
https://github.com/doctrine/doctrine2/pull/1374

Comment by Doctrine Bot [ 06/Apr/15 ]

A related Github Pull-Request [GH-1374] was labeled:
https://github.com/doctrine/doctrine2/pull/1374

Comment by Doctrine Bot [ 06/Apr/15 ]

A related Github Pull-Request [GH-1374] was merged:
https://github.com/doctrine/doctrine2/pull/1374





[DDC-3669] [GH-1373] Add note about "symfony/yaml" dependency for yml mappings Created: 05/Apr/15  Updated: 06/Apr/15  Resolved: 06/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: composer, dependency, mapping, symfony, yaml


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1373

Message:



 Comments   
Comment by Doctrine Bot [ 06/Apr/15 ]

A related Github Pull-Request [GH-1373] was assigned:
https://github.com/doctrine/doctrine2/pull/1373





[DDC-3667] Fetch-joining a collection that has a field with a default value of `array` causes a fatal error Created: 05/Apr/15  Updated: 05/Apr/15  Resolved: 05/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.5
Fix Version/s: 2.5.1, 2.6.0
Security Level: All

Type: Bug Priority: Critical
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: collection, default-value, dql, fetch-join, hydrator, persistent-collection


 Description   

With a class like:

class Foo { private $bar = []; }

Fetch-joining like following (with fetch-joined results) will cause a fatal error:

SELECT f, b FROM Foo f JOIN f.bar b





[DDC-3658] [GH-1365] fix rare query test failures due to nondeterminism without order by clause Created: 03/Apr/15  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.5
Fix Version/s: 2.5.1, 2.6.0
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: ci, orderBy, orderby, sorting, testing, tests, testsuite, travis


 Description   

This issue is created automatically through a Github pull request on behalf of zeroedin-bill:

Url: https://github.com/doctrine/doctrine2/pull/1365

Message:

I was wondering why [this travis testrun](https://travis-ci.org/doctrine/doctrine2/jobs/57045280) failed. I investigated and found that the queries involved did not have order by clauses, but were assuming that the query result would return in the same order in which the records were persisted. This is not guaranteed to be the case on most RDBs.

This PR simply adds an order by clause to the queries that will produce a deterministic result and prevent spurious test failures.



 Comments   
Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1365] was assigned:
https://github.com/doctrine/doctrine2/pull/1365

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1365] was closed:
https://github.com/doctrine/doctrine2/pull/1365





[DDC-3664] [GH-1369] Drop empty file Created: 04/Apr/15  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: documentation, empty-file, markdown


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1369

Message:



 Comments   
Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1369] was assigned:
https://github.com/doctrine/doctrine2/pull/1369

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1369] was labeled:
https://github.com/doctrine/doctrine2/pull/1369

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1369] was merged:
https://github.com/doctrine/doctrine2/pull/1369





[DDC-3666] [GH-1371] Readme: drop "Downloads" link Created: 04/Apr/15  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: documentation, download, link


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1371

Message:

Probably deprecated option



 Comments   
Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1371] was assigned:
https://github.com/doctrine/doctrine2/pull/1371





[DDC-3665] [GH-1370] drop doctrine/common git submodule Created: 04/Apr/15  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: cleanup, git, git-submodule


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1370

Message:

This is managed by composer now



 Comments   
Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1370] was assigned:
https://github.com/doctrine/doctrine2/pull/1370

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1370] was labeled:
https://github.com/doctrine/doctrine2/pull/1370

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1370] was merged:
https://github.com/doctrine/doctrine2/pull/1370





[DDC-3663] [GH-1368] Readme: coverage badge for 2.4 added Created: 04/Apr/15  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: badges, ci, coverage, documentation


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1368

Message:

I didn't know 2.4 has coverage too. It would be nice to show it too, when it's still active.



 Comments   
Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1368] was assigned:
https://github.com/doctrine/doctrine2/pull/1368

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1368] was merged:
https://github.com/doctrine/doctrine2/pull/1368





[DDC-3660] [GH-1367] Made \Doctrine\ORM\Mapping\Driver\DatabaseDriver bit more adapted for extending Created: 04/Apr/15  Updated: 04/Apr/15  Resolved: 04/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: database-driver, extensibility, reverse-engineering


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1367

Message:



 Comments   
Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1367] was assigned:
https://github.com/doctrine/doctrine2/pull/1367

Comment by Doctrine Bot [ 04/Apr/15 ]

A related Github Pull-Request [GH-1367] was closed:
https://github.com/doctrine/doctrine2/pull/1367





[DDC-3659] [GH-1366] [Documentation] typo fixes Created: 03/Apr/15  Updated: 03/Apr/15  Resolved: 03/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: documentation, typo


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1366

Message:



 Comments   
Comment by Doctrine Bot [ 03/Apr/15 ]

A related Github Pull-Request [GH-1366] was assigned:
https://github.com/doctrine/doctrine2/pull/1366

Comment by Doctrine Bot [ 03/Apr/15 ]

A related Github Pull-Request [GH-1366] was labeled:
https://github.com/doctrine/doctrine2/pull/1366

Comment by Doctrine Bot [ 03/Apr/15 ]

A related Github Pull-Request [GH-1366] was merged:
https://github.com/doctrine/doctrine2/pull/1366





[DDC-3657] [GH-1364] [Documentation] correct naming of Embeddable Objects feature Created: 03/Apr/15  Updated: 03/Apr/15  Resolved: 03/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: 2.5
Fix Version/s: 2.5.1
Security Level: All

Type: Documentation Priority: Trivial
Reporter: Doctrine Bot Assignee: Bill Schaller
Resolution: Fixed Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1364

Message:



 Comments   
Comment by Doctrine Bot [ 03/Apr/15 ]

A related Github Pull-Request [GH-1364] was merged:
https://github.com/doctrine/doctrine2/pull/1364





[DDC-3561] Wrong SQL generated for Drop Foreign Key on MySQL Created: 06/Feb/15  Updated: 03/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

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

operating system: osx yosemite
database driver: pdo_mysql
installed bundles:
doctrine/annotations v1.2.3
doctrine/cache v1.4.0
doctrine/collections v1.2
doctrine/common v2.4.2
doctrine/data-fixtures dev-master ac36ccc
doctrine/dbal v2.5.1
doctrine/doctrine-bundle v1.3.0
doctrine/doctrine-cache-bundle v1.0.1
doctrine/doctrine-fixtures-bundle v2.2.0
doctrine/doctrine-migrations-bundle dev-master 81575a4
doctrine/inflector v1.0.1
doctrine/instantiator 1.0.4
doctrine/lexer v1.0.1
doctrine/migrations dev-master 96f838b
doctrine/mongodb 1.1.6
doctrine/mongodb-odm dev-master 23152aa
doctrine/mongodb-odm-bundle dev-master 9748d11
doctrine/orm v2.4.7
gedmo/doctrine-extensions v2.3.9
stof/doctrine-extensions-bundle v1.1.0


Attachments: File migrate-example.php    

 Description   

i´m new to doctrine, but it seems to me that there is a problem creating statements in migrations.
Please see the //comments in the attached file!



 Comments   
Comment by Marco Pivetta [ 06/Feb/15 ]

Steve Müller I think I saw this issue already in the DBAL tracker somewhere, but I can't find it. Do you remember the issue ID?

Comment by Stefan Gnann [ 06/Feb/15 ]

The attached file was automatically generated after upgrading doctrine/dbal onto version 2.5.1 .

Now i have DOWNgraded doctrine/dbal to version 2.4.4 .
Suddenly the doctrine:migrations:diff says "No changes detected in your mapping information.".

Before downgrading i had two identical databases. One locally installed and one in a vagrant box with debian as os.
On every database i did a "doctrine:migrations:diff" to generate an actual schema update file. What i was wondering ist, that i got two different files with different ALTER xxxxx statements regarding to FOREIGN KEY and INDEXES.

Maybe this is a bug in doctrine/dbal 2.5.1?

Comment by Stefan Gnann [ 06/Feb/15 ]

actual installed bundles after downgrading:

doctrine/annotations v1.2.3
doctrine/cache v1.4.0
doctrine/collections v1.2
doctrine/common v2.4.2
doctrine/data-fixtures dev-master 80401e8
doctrine/dbal v2.4.4
doctrine/doctrine-bundle v1.3.0
doctrine/doctrine-cache-bundle v1.0.1
doctrine/doctrine-fixtures-bundle v2.2.0
doctrine/doctrine-migrations-bundle dev-master 81575a4
doctrine/inflector v1.0.1
doctrine/instantiator 1.0.4
doctrine/lexer v1.0.1
doctrine/migrations dev-master 1ac14fa
doctrine/mongodb 1.1.7
doctrine/mongodb-odm dev-master 1343375
doctrine/mongodb-odm-bundle dev-master 27e7690
doctrine/orm v2.4.7
gedmo/doctrine-extensions v2.3.11
stof/doctrine-extensions-bundle v1.1.0

Comment by Peter Rehm [ 18/Feb/15 ]

Steve Müller I did some research on that the last days and I am sure, there is still a major issue with the implementation.

The schema update creates the following sql commands:

$this->addSql('ALTER TABLE Article DROP FOREIGN KEY FK_12743CF7924C3225');
$this->addSql('ALTER TABLE Article DROP FOREIGN KEY FK_12743CF79395C3F3');
$this->addSql('ALTER TABLE Article DROP FOREIGN KEY FK_12743CF7F7C5BCDB');
$this->addSql('ALTER TABLE Article DROP FOREIGN KEY FK_93173F21A23B42D');
$this->addSql('ALTER TABLE Article DROP FOREIGN KEY FK_93173F21A5790FE9');
$this->addSql('ALTER TABLE Article ADD CONSTRAINT FK_12743CF7924C3225 FOREIGN KEY (createdUser_id) REFERENCES CoreUser (id)');

Looking at the previous SQL schema I found out that there is already e.g. the FK_12743CF7924C3225. This FK
will be dropped and newly added at the same time. It is actually not using the new FK name which doctrine would
like to see. However in the down sql it tried to drop the key which should be there.

In addition to that there is an issue with upper/lowercase Index names. This I got fixed by

return 'DROP INDEX ' . strtoupper($indexName) . ' ON ' . $table;

in MysqlPlatform:860 which is most likely not the right way. I am more concerned about the FK
issue, which I am unable to track down so far. Do you have any idea?

Comment by Peter Rehm [ 20/Mar/15 ]

@deeky666 Have you had a chance to look at this?

Comment by Marco Pivetta [ 03/Apr/15 ]

Maybe relevant, but I'm still clueless myself: https://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html





[DDC-3656] [GH-1363] remove disclaimer about ORM 2.5 being in beta Created: 03/Apr/15  Updated: 03/Apr/15  Resolved: 03/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.5, 2.6.0
Security Level: All

Type: Documentation Priority: Minor
Reporter: Doctrine Bot Assignee: Bill Schaller
Resolution: Fixed Votes: 0
Labels: documentation


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1363

Message:



 Comments   
Comment by Doctrine Bot [ 03/Apr/15 ]

A related Github Pull-Request [GH-1363] was merged:
https://github.com/doctrine/doctrine2/pull/1363

Comment by Doctrine Bot [ 03/Apr/15 ]

A related Github Pull-Request [GH-1363] was assigned:
https://github.com/doctrine/doctrine2/pull/1363





[DDC-3655] [GH-1362] Readme: badges for 2.5 added; 2.3- dropped Created: 03/Apr/15  Updated: 03/Apr/15  Resolved: 03/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.6.0
Security Level: All

Type: Documentation Priority: Minor
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: badges, documentation, readme


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1362

Message:

If I understand [2.5 release info](https://github.com/doctrine/doctrine2/releases/tag/v2.5.0) correctly, 2.4 will have last bugfix, then security fixes. I suppose then 2.3 and lower are in EOL, thus not needed to check badge for. Also they don't have any branch.






[DDC-3649] [GH-1356] Introduced skipNamespaceInPath and skipNamespacePartInPath properties Created: 01/Apr/15  Updated: 02/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1356

Message:

Hi All,

I've extended the EntityGenerator in order to make handling of namespaces more flexible. Currently the EntityGenerator class creates a full tree based on the namespace under the output-directory. This causes problems in a PSR-4-like environment. Thus, i've introduced two properties in order to manipulate the target path:

skipNamespaceInPath: if true, every class file is put directly into the output-directory. if false (which is the default and equal to the current behaviour), subdirectories based on the namespace are generated.

skipNamespacePartInPath: the part of the namespace to skip, for example if the namespace is 'Foo\Bar\Entities\MyEntity', and skipNamespacePartInPath is set to 'Foo\Bar', the entity MyEntity is generated in the directory 'Entities' under the output-directory.

Andreas



 Comments   
Comment by Doctrine Bot [ 01/Apr/15 ]

A related Github Pull-Request [GH-1356] was labeled:
https://github.com/doctrine/doctrine2/pull/1356

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1356] was assigned:
https://github.com/doctrine/doctrine2/pull/1356





[DDC-3654] [GH-1360] Fixed misleading typo in Embeddables tutorial Created: 02/Apr/15  Updated: 02/Apr/15  Resolved: 02/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation, Mapping Drivers
Affects Version/s: 2.5
Fix Version/s: 2.5.1, 2.6.0
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: column, column-prefix, documentation, embeddables


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1360

Message:



 Comments   
Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1360] was assigned:
https://github.com/doctrine/doctrine2/pull/1360

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1360] was merged:
https://github.com/doctrine/doctrine2/pull/1360

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1360] was labeled:
https://github.com/doctrine/doctrine2/pull/1360





[DDC-3653] [GH-1359] Fixed typo in the documentation Created: 02/Apr/15  Updated: 02/Apr/15  Resolved: 02/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: 2.5
Fix Version/s: 2.5.1, 2.6.0
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: annotation, documentation, mapping, typo


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1359

Message:



 Comments   
Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1359] was assigned:
https://github.com/doctrine/doctrine2/pull/1359

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1359] was labeled:
https://github.com/doctrine/doctrine2/pull/1359

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1359] was merged:
https://github.com/doctrine/doctrine2/pull/1359





[DDC-3651] [GH-1358] Update docs for clear-cache commands Created: 01/Apr/15  Updated: 02/Apr/15  Resolved: 02/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation, Tools
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: cache, clear-cache, cli, documentation


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1358

Message:

The current docs appear to refer to an older version of the clear-cache commands.

The "clear all caches" command doesn't appear to exist anymore, and the three more specific options for clearing the metadata, query, and result caches are now separate tasks instead of options on one.



 Comments   
Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1358] was labeled:
https://github.com/doctrine/doctrine2/pull/1358

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1358] was assigned:
https://github.com/doctrine/doctrine2/pull/1358

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1358] was merged:
https://github.com/doctrine/doctrine2/pull/1358





[DDC-3648] [GH-1355] [Docs] TablePrefix example - Check for being the owning side Created: 01/Apr/15  Updated: 02/Apr/15  Resolved: 02/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: cookbook, documentation


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1355

Message:

  • Small fix do get rid of notice `undefined index 'joinTable'` as the inverse side does not declare `joinTable` at all.
  • Shortened access to `$classMetadata->associationMappings[$fieldName]` for read accesses to increase readability


 Comments   
Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1355] was assigned:
https://github.com/doctrine/doctrine2/pull/1355

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1355] was merged:
https://github.com/doctrine/doctrine2/pull/1355





[DDC-3650] [GH-1357] Drop useless execution bit Created: 01/Apr/15  Updated: 02/Apr/15  Resolved: 02/Apr/15

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Major
Reporter: Doctrine Bot Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: file-mode, paginator


 Description   

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

Url: https://github.com/doctrine/doctrine2/pull/1357

Message:



 Comments   
Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1357] was assigned:
https://github.com/doctrine/doctrine2/pull/1357

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1357] was labeled:
https://github.com/doctrine/doctrine2/pull/1357

Comment by Doctrine Bot [ 02/Apr/15 ]

A related Github Pull-Request [GH-1357] was merged:
https://github.com/doctrine/doctrine2/pull/1357





[DDC-3410] Allow Query Builder to specify the joins of Join Inheritance entities Created: 25/Nov/14  Updated: 02/Apr/15

Status: Open
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Minor
Reporter: Dave Newson Assignee: Benjamin Eberlei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Reference
is referenced by DDC-3652 Problem with joins between entities w... Open

 Description   

Possibly a duplicate of DDC-16 in essence; resolving this would probably resolve that issue.

Summary
When you SELECT an entity which is a superclass using Joined Inheritance, Doctrine automatically adds it's own JOINs of the superclass or subclass tables.
These automatic JOINs that are introduced can't be used in DQL/builder, so you can't do anything with them (further joins on their associations for eager loading, WHERE queries, etc).
Allow me to specify my own Joins between the superclass and subclass so I can perform further queries deeper in the associations.

Main culprit:
https://github.com/doctrine/doctrine2/blob/2.4/lib/Doctrine/ORM/Query/SqlWalker.php#L341

Long version
Superclass "Activity" uses the Joined inheritance type with a discriminator column. There are various activities such as ActivityDocument, ActivityTask, etc.
These sub-class activities have associations to other entities; ActivityDocument associates to a Document entity, and Document then associates to User.

For the query, I want to fetch all Activity where the Activities document/task is associated to a given user. If I wanted to do this in raw SQL it would look something like this:

SELECT a.*, ad.*, d.*, at.*, t.*
FROM Activity a
LEFT JOIN ActivityDocument ad ON ad.id = a.id
LEFT JOIN Document d ON d.id = ad.document_id
LEFT JOIN ActivityTask at ON at.id = a.id
LEFT JOIN Task t ON t.id = at.task_id
WHERE
t.user_id = 1 OR d.user_id = 1

Doctrine supports the joined inheritance type, so I want it to fetch the subclasses and also eagerly load the downstream Document or Task entity that's associated with them, and be able to execute clauses on the data.

I can only get half way there:

$builder
    ->select('a')
    ->from('Activity', 'a')
    ->leftJoin('ActivityDocument', 'ad', Query\Expr\Join::WITH, 'a.id = ad.id')
    ->leftJoin('ad.document', 'ad_d')
    ->orWhere('ad_d.user = :user')
    ->leftJoin('ActivityTask', 'at', Query\Expr\Join::WITH, 'a.id = at.id')
    ->leftJoin('at.task', 'at_t')
    ->orWhere('at_t.user = :user')
    ->setParameter('user', $user);

In the above I've fudged the joined inheritance association using ->leftJoin() in order to execute the deep WHERE portion, however because we're doing our own join between two entities, the association between Activity and ActivityDocument is lost.

The entities returned by this query are instances of ActivityDocument and ActivityTask; the hydrated subclasses are returned when we SELECT from Activity, and ActivityDocument and ActivityTask are LEFT JOINed automatically by Doctrine because the Activity entity is recognised as using Joined Inheritance, but there's no way to latch onto these generated LEFT JOINs.
https://github.com/doctrine/doctrine2/blob/2.4/lib/Doctrine/ORM/Query/SqlWalker.php#L376

Note that adding "ad", "at" or "at_d" or "at_t" to the select does not solve this.

A workaround for this specific scenario is this:

$builder->select('ad', 'at', 'ad_d', 'at_t')

This fetch ActivityDocument and ActivityTask specifically, plus their associations. Unfortunately because it is across multiple to-level entities, it causes null rows to be returned in the result set.

Effectively this goes the other way, and adds joins from ActivityDocument to Activity in order to provide the correct hydration of ActivityDocument.
https://github.com/doctrine/doctrine2/blob/2.4/lib/Doctrine/ORM/Query/SqlWalker.php#L348

Note that you still cannot use an alias for Activity because the builder was not the one to specify that relation.

What I want to be able to do
Allow me to define the join across the Join Inheritance entities, so I can use the alias for the superclass/subclass in the query builder!

Rather than DDC-16's idea of "casting" to a class, just let me define the join myself. Obviously this is more a "joined class" than a "joined field" , so extra notation may be required.
A painfully ugly example of this syntax could be something like:

$builder->join('Activity->ActivityDocument', 'ad')

This could then establish the Join as some form of JoinAssociation rather than a RangeVariableDeclaration.

The bigger problem is that SqlWalker::_generateClassTableInheritanceJoins doesn't have scope over any of the joins in the query, and thus can't inspect any relations that have been established in the query builder, and use those instead of generating its own.

Unfortunately I don't know the internals of Doctrine to be of any more use.

Why
Joined Inheritance is a powerful feature, but without being able to use associations across the superclass and subclass it actually creates an annoying dead-end in queries.

There is no good workaround for this issue. If you fetch a Join Inheritance entity you can only examine one side of the inheritance without performing another query.






[DDC-3361] Doctrine error while trying to execute a DQL query on PostgreSQL 9.2.x Created: 23/Oct/14  Updated: 31/Mar/15