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






Generated at Fri May 22 19:04:36 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.