[DDC-1986] findBy hydration with limit and offset with Oracle database (oci8 driver) Created: 17/Aug/12 Updated: 08/Jan/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Grandfond | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | oracle | ||
| Environment: |
composer.json require : "php": ">=5.3.3", |
||
| Description |
|
I tried to use the findBy method with limit and offset parameters against an Oracle database using oci8 driver. The query seems to executed successfully but the hydrator fails when hydrating data as there is a DOCTRINE_ROWNUM column appending the "limit" clause. Here is the exception thrown : "Notice: Undefined index: DOCTRINE_ROWNUM in [...]/vendor/doctrine/orm/lib/Doctrine/ORM/Internal/Hydration/SimpleObjectHydrator.php line 183" I was thinking about something like this to fix this issue
Maybe there is a better approach, what are your thoughts? |
| Comments |
| Comment by Benjamin Grandfond [ 17/Aug/12 ] |
|
I implemented it in my forks : https://github.com/benja-M-1/doctrine2/commit/c8d899b14446accf869ddc0043f4235284375755 It works for me, but I didn't write unit tests. |
| Comment by Benjamin Grandfond [ 24/Aug/12 ] |
|
Hi, Did you have time to have a look at this issue? Thanks |
| Comment by Christophe Coevoet [ 24/Aug/12 ] |
|
Please send a pull request when you submit a fix. It is the proper way to submit them for review. When we want to see things waiting for review, we look at the list of pending PRs, not at all comments of the issue tracker to find links in them. And I can tell you that this change has a big issue: it introduces a state in the database platform whereas it is currently stateless. This is likely to cause some issues when using more than 1 query (which is a common use case). |
| Comment by Benjamin Grandfond [ 29/Aug/12 ] |
|
Hi Christophe thank you for your feedback. I didn't send a PR because I wanted someone sharing his thoughts about what I suggested in this current issue. However I don't really understand the stateless argument, can you explain a bit more? Otherwise how would do you proceed to tell Doctrine not to hydrate platform-specific columns? |
| Comment by Christophe Coevoet [ 29/Aug/12 ] |
|
If you run several queries, they will be affected by the extra columns of previous requests, which is wrong |
| Comment by Benjamin Eberlei [ 29/Aug/12 ] |
|
I think the ObjectHydrator catches this by skipping undefined columns, i think we might just have overoptimized the SimpleObjectHydrator a little bit. |
[DDC-1879] Orphans are neither nulled nor removed when merging a graph of detached entities Created: 18/Jun/12 Updated: 23/Jan/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Philippe Van Eerdenbrugghe | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine 2.2.2 |
||
| Description |
|
When merging a graph of detached entities, the created entitied are created and the updated entities are updated but the non-present entities (which exist in the database but are not in the graph) are neither removed nor have them their association column nullified. Example : In my code I have 2 entities : Parent and Child. There is a OneToMany(cascade= {"all"}, orphanRemoval=true) relation defined in Parent. In my database I have a Parent row with an id of 1, which has 3 Children with ids 1,2,3. When I write the following code, I expect the Parent with id 1 and the Child with id 2 to be updated, a new Child to be created and the Child with id 1 and 3 to be deleted. $parent = new Parent(); $parent->id = 1 // detached entity $existing_child = new Child(); $child->id = 2 // detached entity $new_child = new Child(); // new entity $dinner->addChild($existing_child); $dinner->addChild($new_child); $em->merge($dinner); $em->flush(); The objects I expect to be created and updated have the correct behaviour but the old children are not touched, they are still present in the database. |
| Comments |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
I don't think this is valid. Orphan removal scheduling is handled only when an unit of work is available. What's the state of `$dinner` before your example? Can you `var_dump` it? |
[DDC-1803] Paginator usage with a DQL query that is using 2 time the same named binded value failed Created: 30/Apr/12 Updated: 25/Jan/13 |
|
| 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: | Marc Drolet | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
linux, oracle |
||
| Description |
|
I use a dql query where I bind a named parameter 2 time in the same query for different joined fields. The query work but the count query failed saying that there are missing bind variable. ex: , partial ca.{id} , ') $onTheMarket = new Paginator($qb, $fetchJoin = true); To make it work, I've renamed the second usage of the named variable with a 2 at the end. deleted2 and published2. |
| Comments |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
This seems to be quite old. Marc Drolet is it still valid with the latest ORM? |
| Comment by Marc Drolet [ 25/Jan/13 ] |
|
I'll try to test this problem on an updated version and I'll let you know. |
| Comment by Marco Pivetta [ 25/Jan/13 ] |
|
Ok, marking as awaiting feedback |
[DDC-2193] Named native query bug? Created: 11/Dec/12 Updated: 31/Dec/12 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | dingdangjyz | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
@NamedNativeQueries is a useful thing, but I have found some problems during my using.
/**
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "fetchMultipleJoinsEntityResults",
* resultSetMapping= "mappingMultipleJoinsEntityResults",
* query = "SELECT * FROM test "
* )
* })
*/
2、Error,cannot connect to the server
/**
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "fetchMultipleJoinsEntityResults",
* resultSetMapping= "mappingMultipleJoinsEntityResults",
* query = "SELECT *
FROM test "
* )
* })
*/
3、Cannot use alias.The same problem as the second one.
.......
query = "SELECT a as test FROM test "
|
| Comments |
| Comment by Fabio B. Silva [ 12/Dec/12 ] |
|
Hi Doctrine does not change the native query at all Could you provide more details please? Cheers |
| Comment by dingdangjyz [ 13/Dec/12 ] |
|
Doctrine\Common\Lexer.php Hello, after checking, I found the problem should be here. As long as SQL wrap, or fill in alias, it will be error. It seems to be the preg_split problem?
$flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
$matches = preg_split($regex, $input, -1, $flags);
foreach ($matches as $match) {
// Must remain before 'value' assignment since it can change content
$type = $this->getType($match[0]);
$this->tokens[] = array(
'value' => $match[0],
'type' => $type,
'position' => $match[1],
);
|
| Comment by Fabio B. Silva [ 13/Dec/12 ] |
|
Hi Could you try to add a failing test case please ? Cheers |
| Comment by dingdangjyz [ 14/Dec/12 ] |
|
xp php5.3.8 Apache
<?php
namespace Models\Entities;
/**
* @Entity
* @Table
*
* @NamedNativeQueries({
* @NamedNativeQuery(
* name = "find-hotel-item",
* resultSetMapping = "mapping-find-item",
* query = "SELECT Top 1 VEI_SN AS SN
FROM tourmanager.dbo.VEndorInfo vi
INNER JOIN tourmanager.dbo.VEndorInfo2 vi2 ON
vi.VEI_SN = vi2.VEI2_VEI_SN LEFT OUTER JOIN tourmanager.dbo.HotelInfo hi
ON hi.hotelid = vi2.VEI2_VEI_SN INNER JOIN tourmanager.dbo.HotelInfo2
hi2 ON hi2.hotelid = vi2.VEI2_VEI_SN AND hi2.LGC = 1 "
* )
* })
*
* @SqlResultSetMappings({
* @SqlResultSetMapping(
* name = "mapping-find-item",
* entities= {
* @EntityResult(
* entityClass = "HTHotelItem",
* fields = {
* @FieldResult(name = "id", column="SN")
* }
* )
* }
* )
* })
*
*/
class HTHotelItem{
/** @Id @Column(type="integer") @GeneratedValue */
protected $id;
/** @name */
protected $name;
/** @city */
protected $city;
/** @url */
protected $url;
public static function loadMetadata(\Doctrine\ORM\Mapping\ClassMetadataInfo $metadata){
$metadata->addNamedNativeQuery(array(
'name' => 'find-hotel-item',
'query' => 'SELECT h FROM HTHotelItem h',
'resultSetMapping' => '\\Models\\Entities\\HTHotelItem'
));
}
function getId(){
return $this->id;
}
function getName(){
return $this->name;
}
function getCity(){
return $this->city;
}
function getUrl(){
return $this->url;
}
}
|
| Comment by dingdangjyz [ 14/Dec/12 ] |
|
@NamedNativeQueries query If we write the long SQL, it will be fault. NO error massage. |
| Comment by Fabio B. Silva [ 16/Dec/12 ] |
|
Can't reproduce, Could you try to change the attached test case and make it fail. Cheers |
| Comment by Benjamin Eberlei [ 24/Dec/12 ] |
|
The Doctrine\Common\Lexer is never used in combination with native queries, only with the Annotation Parser, so i cannot be the preg_split that causes your SQL to be broken. Or do you get annotation errors? Also what database are you using? maybe its related to the DBAL sql parsing? |
| Comment by dingdangjyz [ 31/Dec/12 ] |
|
I'm sorry my English is too bad. I think it's Doctrine \ is \ Lexer. PHP preg_split the function of the problem in this file. |
[DDC-2424] Removing an inherited entity via a delete cascade constraint does not remove the parent row Created: 02/May/13 Updated: 06/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.3.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | Bruno Jacquet | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Mysql 5.1.66 / Symfony 2.2.1 |
||
| Description |
|
For a parent class: /** * @ORM\Entity * @ORM\Table(name="Base") * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({"child1" = "Child1", "child2" = "Child2"}) */ and simple Child1 & Child2 entities. With another entity (let's call it ExternalEntity) having a bidirectional OneToOne relation owned by Child1: class Child1 extends Base { /** * @ORM\OneToOne(targetEntity="ExternalEntity", inversedBy="xxx") * @ORM\JoinColumn(onDelete="CASCADE", nullable=false) */ private theForeignKey; } Enough for the context. $em->remove(instanceOfExternalEntity); removes the ExternalEntity row and the Child1 row. But a dangling row in the Base table is still there for the now inexistent Child1 instance. Though, a manual delete of either the associated Child1 OR Base row and then the ExternalEntity works. The problem with the cascading deletion of the parent seems to be only present when deleting through a MYSQL cascading delete from another row which has a foreign key on a child. (Not tested with a foreign key on the parent though) |
| Comments |
| Comment by Benjamin Eberlei [ 04/May/13 ] |
|
Can you show the CREATE TABLE and FOREIGN KEY statements of all the tables involved? It seems the cascade of the foreign keys is not propagated between multiple tables? |
| Comment by Bruno Jacquet [ 06/May/13 ] |
|
CREATE TABLE Base (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; ALTER TABLE Child1 ADD CONSTRAINT FK_179B6E88E992F5A FOREIGN KEY (foreignKey) REFERENCES ExternalEntity (id) ON DELETE CASCADE; |
| Comment by Bruno Jacquet [ 06/May/13 ] |
|
The problem is that, the SQL model never explicitely tells the DB to delete the corresponding Base when Child1 gets removed. It looks like it is handled by the doctrine entity manager layer and not the actual DB engine (Base has no on delete cascade nor foreign key to its children). |
| Comment by Bruno Jacquet [ 06/May/13 ] |
|
Maybe using cascade={"remove"}
, instead of onDelete="CASCADE"
to force the cascading process to be handled by doctrine would workaround the bug... But I prefer to have my DB do the logic work as much as possible. |
[DDC-2147] Custom annotation in MappedSuperclass Created: 15/Nov/12 Updated: 07/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers, ORM |
| Affects Version/s: | 2.2.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | kluk | Assignee: | Marco Pivetta |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux 3.6.6-1.fc17.x86_64 |
||
| Attachments: |
|
| Description |
|
When you try use custom annotation in mappedsuperclass like here http://pastebin.com/YMxKvcLk and then i try get metadata for class i get this error |
| Comments |
| Comment by kluk [ 15/Nov/12 ] |
|
error log from orm:validate-schema |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
Copying from pastebin: use \Doctrine\ORM\Mapping as ORM; use \xxx\Doctrine\Annotation\Entity as re; use \xxx\Doctrine\Annotation\Forms as rf; use \Doctrine\Common\Collections; /** * @ORM\Entity */ class EventPicture extends \Picture { /** * @ORM\ManyToOne(targetEntity="Event", inversedBy="eventPicture") * @ORM\JoinColumn(name="FK_Event", referencedColumnName="id") */ protected $event; } use \Doctrine\ORM\Mapping as ORM; use \xxx\Doctrine\Annotation\Entity as re; use \xxx\Doctrine\Annotation\Forms as rf; use \Doctrine\Common\Collections; /** @ORM\MappedSuperclass */ class Picture extends \xxx\Doctrine\Entity\BaseEntity { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="IDENTITY") * @var type */ protected $id; /** * @ORM\Column(type="string",unique=true, nullable=false) * @rf\FileUpload(fileSize="php",uploadType="local",fieldName="link",formControl="FileUploadField",image=true) * */ protected $link; } kluk does this happen also with any other simple custom annotation? For example following:
/**
* @Annotation
* @Target({"PROPERTY","ANNOTATION"})
*/
final class Entity implements Annotation
{
/**
* @var string
*/
public $value;
}
|
| Comment by kluk [ 30/Jan/13 ] |
|
the same error when using simple annotation.
<?php
use \Doctrine\ORM\Mapping as ORM;
use \xxx\Doctrine\Annotation\Entity as re;
use \xxx\Doctrine\Annotation\Forms as rf;
use \Doctrine\Common\Collections;
/** @ORM\MappedSuperclass */
class Picture extends \xxx\Doctrine\Entity\BaseEntity {
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="IDENTITY")
* @var type
*/
protected $id;
/**
* @ORM\Column(type="integer")
* @rf\SetClass({"class","hide"})
*/
public $value;
/**
* @ORM\Column(type="string",unique=true, nullable=true)
* @rf\FileUpload(fileSize="php",uploadType="local",fieldName="link",formControl="FileUploadField",image=true)
*
*/
protected $link;
}
When i remove $value , $picture from class everything goes ok.
/**
* INTERNAL:
* Adds a field mapping without completing/validating it.
* This is mainly used to add inherited field mappings to derived classes.
*
* @param array $fieldMapping
*
* @return void
*/
public function addInheritedFieldMapping(array $fieldMapping)
{
if(isset($fieldMapping['fieldName'])){
$this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping;
$this->columnNames[$fieldMapping['fieldName']] = $fieldMapping['columnName'];
$this->fieldNames[$fieldMapping['columnName']] = $fieldMapping['fieldName'];
}
}
But i dont know if this fix can break another part of doctrine. |
| Comment by Benjamin Eberlei [ 04/May/13 ] |
|
Can you put the code of your annotations online? I can't seem to understand why this happens. |
| Comment by kluk [ 07/May/13 ] |
|
Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml namespace libs\Doctrine\Annotation\Entity; use Doctrine\Common\Annotations\Annotation; /** @Annotation */ class CustomMapping extends Annotation { /** * * @var string */ public $className; /** * * * @var IQueryable| string */ public $dataSource; } |
[DDC-2449] Amazon Redshift Support Created: 15/May/13 Updated: 15/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Kirill F | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Amazon Redshift |
||
| Description |
|
It would be nice to get doctrine compatible with Amazon Redshift. It uses a Postgres connector but there are some differences. I'm currently facing an issue with the primary id, in Redshift the generation of an id is different from Postgres and so I'm getting errors associated with generating an id. Here are some references that might be useful: Amazon Manual: |
[DDC-2035] XML Mapping : add attribute "length" for tag "id" Created: 20/Sep/12 Updated: 29/Sep/12 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Minor |
| Reporter: | Erik Müller | Assignee: | Fabio B. Silva |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux, Doctrine ORM 2.3.0, MySQL |
||
| Description |
|
XML mapping : <id name="id" type="string" length="16"/> Generate SQL : id varchar(255) not null
It's not possible with XML mapping to have : id varchar(16) not null
Because tag "id" doesn't support "length" attribute. |
| Comments |
| Comment by Fabio B. Silva [ 20/Sep/12 ] |
|
Hi Erik, The atribute "id" arealdy support "length" in the current doctrine version Which version are you using ? |
[DDC-1630] Get PersistentCollection::getDeleteDiff is empty when collection changes from 1 item to zero items Created: 31/Jan/12 Updated: 09/Feb/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Minor |
| Reporter: | Lee | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | None | ||
| Environment: |
Symfony2 |
||
| Attachments: |
|
| Comments |
| Comment by Steve Müller [ 09/Feb/12 ] |
|
Same problem here. I wanted to write some unit tests, checking the entity relations and ran into exactly the same problem. Maybe my code can provide some more information (Group entity is the owning side, role entity is the inverse side): WHAT DOES NOT WORK: /**
* Test ArrayCollection
*/
$group = new Group('Group Test');
$em->persist($group);
$em->flush();
$groups = new ArrayCollection();
$groups->add($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
/**
* Test PersistentCollection
*/
$em->persist($this->role);
$em->flush();
$groups = $this->role->getGroups();
$groups->removeElement($group); // first remove element before adding a new one
$group = new Group('Group Test 2');
$em->persist($group);
$em->flush();
$groups->add($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
WHAT WORKS: /**
* Test ArrayCollection
*/
$group = new Group('Group Test');
$em->persist($group);
$em->flush();
$groups = new ArrayCollection();
$groups->add($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
/**
* Test PersistentCollection
*/
$em->persist($this->role);
$em->flush();
$groups = $this->role->getGroups();
$group2 = new Group('Group Test 2');
$em->persist($group2);
$em->flush();
$groups->add($group2); // first adding a new element before removing one
$groups->removeElement($group);
$this->role->setGroups($groups);
$this->assertEquals($groups, $this->role->getGroups());
Hope this helps in any way... I tried figuring it out on my own but I am too drunk right now xD |
| Comment by Benjamin Eberlei [ 10/Feb/12 ] |
|
Thanks for the report, formatted it |
| Comment by Benjamin Eberlei [ 10/Feb/12 ] |
|
Which version is that btw? |
| Comment by Steve Müller [ 16/Feb/12 ] |
|
Occurs in version 2.1.6 |
| Comment by Benjamin Eberlei [ 20/Feb/12 ] |
|
If group is the owning side, why do you only set Role::$groups? This has to be the other way around or not? |
| Comment by Benjamin Eberlei [ 20/Feb/12 ] |
|
@Steve I cannot reproduce your issue. Attached is a test script. Your code is very weird btw, why are you getting and setting groups collection? It is passed by reference so you can just have something like $role->addGroup() and $role->removeGroup() and encapsulate the logic? Also your tests are pretty useless, you check if two variables which are the same reference to the same collection are the same. Which should always be true. @Lee Can you provide more details? I cant verify this without more details. |
| Comment by Alexander [ 09/Feb/13 ] |
|
Can anyone provide us with more feedback? |
[DDC-1494] Query results are overwritten by previous query. Created: 15/Nov/11 Updated: 09/Feb/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Minor |
| Reporter: | J | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3 + MySQL 5.5 |
||
| Attachments: |
|
| Description |
|
I am running a query that JOINs three tables, with a simple WHERE: $q = $em->createQuery("
SELECT cat, n, c
FROM Project_Model_NoticeCategory cat
JOIN cat.notices n
JOIN n.chapters c
WHERE
c.id = :chapter_id
");
When I do this: $q->setParameter('chapter_id', 1);
$a = $q->getResult();
$q->setParameter('chapter_id', 2);
$b = $q->getResult();
$b always has the wrong results. Running the following code: $q->setParameter('chapter_id', 1);
$a = $q->getResult();
$q->setParameter('chapter_id', 2);
$b = $q->getResult();
$z = $q->getArrayResult();
BUG Results: $b != $z (getArrayResult IS CORRECT, it refreshes the results) Note: $a==$b (which is wrong) Explanation: There is a chapter table, this has a many-to-many join to notices (these are meta info Data model: /** * @Entity * @Table(name="chapter") */ class Project_Model_Chapter { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="string") */ private $title; /** * @ManyToMany(targetEntity="Project_Model_Notice", mappedBy="chapters") */ private $notices; .... /lots of code snipped/ .... } /** * @Entity * @Table(name="notice") */ class Project_Model_Notice { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="string") */ private $title; /** * @ManyToMany(targetEntity="Project_Model_Chapter", inversedBy="notices") * @JoinTable(name="chapter_notice") */ private $chapters; /** * @ManyToOne(targetEntity="Project_Model_NoticeCategory", inversedBy="notices") */ private $notice_category; .... /lots of code snipped/ .... } /** * @Entity * @Table(name="notice_category") */ class Project_Model_NoticeCategory { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** @Column(type="string") */ private $title; /** * Bidirectional - One-To-Many (INVERSE SIDE) * * @OneToMany(targetEntity="Project_Model_Notice", mappedBy="notice_category", cascade={"persist", "remove"}) */ private $notices; .... /lots of code snipped/ .... } Data fixtures: $tools = new \Project_Model_NoticeCategory; $tools->setTitle('Tools'); $spanner = new \Project_Model_Notice; $spanner->setTitle('spanner'); $tools->addNotice($spanner); $drill = new \Project_Model_Notice; $drill->setTitle('power drill'); $tools->addNotice($drill); $this->em->persist($tools); $this->em->flush(); $tools = new \Project_Model_NoticeCategory; $tools->setTitle('Safety'); $gloves = new \Project_Model_Notice; $gloves->setTitle('gloves'); $tools->addNotice($gloves); $goggles = new \Project_Model_Notice; $goggles->setTitle('goggles'); $tools->addNotice($goggles); $this->em->persist($tools); $this->em->flush(); $chapter1 = new \Project_Model_Chapter; $chapter1->setTitle('Chapter 1'); $this->em->persist($chapter1); $chapter2 = new \Project_Model_Chapter; $chapter2->setTitle('Chapter 2'); $this->em->persist($chapter2); $chapter1->addNotice($spanner); $chapter1->addNotice($gloves); $chapter2->addNotice($spanner); $chapter2->addNotice($gloves); $chapter2->addNotice($drill); $chapter2->addNotice($goggles); // now persist and flush everything Initial investigation: I think it has something to do with HINT_REFRESH ? Stepping through: ObjectHydrator->_hydrateRow when it requests the Project_Model_Category from the unit of work, it |
| Comments |
| Comment by Benjamin Eberlei [ 15/Nov/11 ] |
|
Fixed formatting |
| Comment by Benjamin Eberlei [ 18/Nov/11 ] |
|
are you using result caching? |
| Comment by J [ 21/Nov/11 ] |
|
This is part of my bootstrap $config = new \Doctrine\ORM\Configuration(); $cache = new \Doctrine\Common\Cache\ArrayCache; $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); // driver: schema $driver = $config->newDefaultAnnotationDriver( APPLICATION_PATH . '/models' ); $config->setMetadataDriverImpl($driver); |
| Comment by Benjamin Eberlei [ 15/Dec/11 ] |
|
Cannot reproduce it with the script attached. Can you try to modify this to fail or write your own testcase? |
| Comment by Benjamin Eberlei [ 15/Dec/11 ] |
|
Downgraded |
| Comment by Alexander [ 09/Feb/13 ] |
|
Please provide extra feedback. |
[DDC-2281] Validation against database-first generated xml requires that the column order within a composite primary key match the order the columns are in in mapping xml Created: 06/Feb/13 Updated: 09/May/13 |
|
| Status: | Awaiting Feedback |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.3.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Minor |
| Reporter: | Aaron Moore | Assignee: | Benjamin Eberlei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In using a database-first approach utilizing orm:convert-mapping to generate xml, the validation and schema-tool reports that my composite primary key (ex. Columns A, C, B) be dropped and added in the order in which the mapping appears in the xml (ex. Columns A, B, C). These columns are not auto-increment and are simply a mixture of int and varchar. |
| Comments |
| Comment by Benjamin Eberlei [ 09/May/13 ] |
|
Is the composite key a mix of association and field types? |
| Comment by Aaron Moore [ 09/May/13 ] |
|
I'm trying to remember the usage as it was a short term project but I believe it is. For example a user has a userid. The table in question might have a primary key consisting of the userid and an int representing a year.. |
[DDC-1377] Doctrine doesn't understand associations from SINGLE_TABLE inheritances Created: 14/Sep/11 Updated: 15/Sep/11 Resolved: 15/Sep/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, Mapping Drivers, ORM |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Marcos Augusto da Silva Garcia | Assignee: | Guilherme Blanco |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Xubuntu 11.04 Linux 2.6.38 i386 |
||
| Issue Links: |
|
||||||||
| Description |
|
Doctrine doesn't understand when a query is built from an association to a SINGLE_TABLE parent to get its successors relations. For example: From a specific Louse, Doctrine can't get the Animal's Bone or Yarn. |
| Comments |
| Comment by Benjamin Eberlei [ 14/Sep/11 ] |
|
Doctrine implements strict OO inheritance, what you want does not work as no casting is currently possible. |
| Comment by Guilherme Blanco [ 15/Sep/11 ] |
|
Reopening |
| Comment by Guilherme Blanco [ 15/Sep/11 ] |
|
Duplicate to |
[DDC-51] Notice: Undefined index: [columnName] in/Doctrine/ORM/Mapping/OneToManyMapping.php on line 129 Created: 15/Oct/09 Updated: 15/Oct/09 Resolved: 15/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Arthur Purnama | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
« Hide Server Version: Apache/2.2.11 (Ubuntu) mod_jk/1.2.26 PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch mysql Ver 14.14 Distrib 5.1.31, for debian-linux-gnu (i486) using EditLine wrapper |
||
| Description |
|
With the same example as i now can not get the ManyToOne association (definitions, proverbs and relations); i got php notice if i check the line the variable $joinColumnValues is an empty array, because the PersistentCollection.php at line 233 did not send any joincolumnvalues to the load method. i dont know if this the cause. i have try to set $entityManager->getConfiguration()->setAllowPartialObjects() to TRUE and make an dql like this but the result is still the same |
| Comments |
| Comment by Roman S. Borschel [ 15/Oct/09 ] |
|
Can you please show the code that you're using. I dont mean the models but the code that causes this problem. Thanks. |
| Comment by Arthur Purnama [ 15/Oct/09 ] |
|
$definitions = $phrase->getDefinitions(); hope this help you. regards, |
| Comment by Roman S. Borschel [ 15/Oct/09 ] |
|
Okay, thanks, I can reproduce this and will work on this. When I'm done I will add all these new tests to the test suite. |
| Comment by Roman S. Borschel [ 15/Oct/09 ] |
|
By the way, eager loading works fine for me. See this snippet:
$query = $this->_em->createQuery("SELECT p,d FROM Doctrine\Tests\ORM\Functional\Phrase p JOIN p.definitions d");
$res = $query->getResult();
$definitions = $res[0]->getDefinitions();
$this->assertEquals(1, count($res));
$this->assertTrue($definitions[0] instanceof Definition);
This works for me. But lazy-loading results in the error you mentioned and which I will fix. |
| Comment by Arthur Purnama [ 15/Oct/09 ] |
|
ok thank you very much it works like charm. du bist Gold Wert Roman please close the ticket. Regards, |
[DDC-50] Call to undefined method Doctrine\ORM\Mapping\OneToManyMapping::getQuotedJoinColumnName() Created: 15/Oct/09 Updated: 15/Oct/09 Resolved: 15/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Arthur Purnama | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3.0 (cli) (built: Jul 21 2009 08:22:07) Server Version: Apache/2.2.11 (Ubuntu) mod_jk/1.2.26 PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch mysql Ver 14.14 Distrib 5.1.31, for debian-linux-gnu (i486) using EditLine wrapper |
||
| Attachments: |
|
| Description |
|
with the $config->setAllowPartialObjects(false); i make an query to but as i try to get the type or lexical member like $phrase->getType() Fatal error: Call to undefined method i read this on doctrine-user groups and i take a look if the line $owningAssoc = $this->_class->associationMappings[$coll->getMapping()->mappedByFieldName]; present on StandardEntityPersister#loadOneToManyCollection. and yes. its present. but i still got this error. |
| Comments |
| Comment by Roman S. Borschel [ 15/Oct/09 ] |
|
Should be fixed now in HEAD. |
[DDC-49] Incomplete MySQL Query Generator (MySQL Syntax error) Created: 15/Oct/09 Updated: 15/Oct/09 Resolved: 15/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Arthur Purnama | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3.0 (cli) (built: Jul 21 2009 08:22:07) Server Version: Apache/2.2.11 (Ubuntu) mod_jk/1.2.26 PHP/5.2.6-3ubuntu4.2 with mysql Ver 14.14 Distrib 5.1.31, for debian-linux-gnu (i486) using EditLine wrapper |
||
| Attachments: |
|
| Description |
|
i checkout the HEAD version. and try to write this DQL $query = utilities\DataAccess::getEntityManager()->createQuery("SELECT i commented out the $config->setAllowPartialObjects(false); and have PDO error that my MySQL statement sytax is invalid. i check the Query that the Doctrine create and its like this : as you can si at the ON statement it writes p0_.phrase_type_id = p1_. the p1_. is not completed. i think my DocAnnotation is OK, because i |
| Comments |
| Comment by Roman S. Borschel [ 15/Oct/09 ] |
|
Should be fixed now in HEAD. |
[DDC-24] text type not portable (works only on MySQL) Created: 30/Sep/09 Updated: 14/Jun/10 Resolved: 01/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.0-ALPHA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Ismo Toijala | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The text type is not portable to other RDBMS than MySQL. To support the text type, a platform must implement the method getClobDeclarationSql(array $field). Currently only MySqlPlatform has this method. This means that attempting to use the CLI tool to create a schema with a text column using another RDBMS fails with the following error: Fatal error: Call to undefined method Doctrine\DBAL\Platforms\SqlitePlatform::getClobDeclarationSql() in D:\Projects\Test\tools\sandbox\lib\Doctrine\DBAL\Types\TextType.php on line 15 I believe at least Sqlite supports the CLOB type. Either the text type should be supported by all platforms or the documentation should be revised. Currently it says: "All Doctrine Mapping Types that ship with Doctrine are fully portable between different RDBMS." This makes easy testing of models using sqlite with minimum configuration impossible with the text type. |
| Comments |
| Comment by Roman S. Borschel [ 30/Sep/09 ] |
|
Thanks. We will try to address this as soon as possible. This is just an oversight in the implementation. The text type can definitely be made portable across all platforms. |
[DDC-513] LEFT JOIN on extended entity of associated entity from parent by @OneToOne throw exception "no such column" [testcase included] Created: 12/Apr/10 Updated: 12/Apr/10 Resolved: 12/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-BETA2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Ondrej Sibrina | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Dear Roman Watch testcase please to understand this issue. Thank you. |
| Comments |
| Comment by Guilherme Blanco [ 12/Apr/10 ] |
|
In http://github.com/doctrine/doctrine2/commit/56a8f5cd5353908b815607a6e089201c95e01e6c this issue was fixed. Thanks for the report and unit test. It saved me a LOT of time! |
[DDC-512] LEFT JOIN of extended null entity cause empty result [testcase included] Created: 12/Apr/10 Updated: 15/Apr/10 Resolved: 15/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Ondrej Sibrina | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Dear developers, I'm not sure about propriety of my query but what i want to do is left class Shop_Data_Entity_StockItem extends Shop_Data_Entity_Item { /** * @OneToOne(targetEntity="Shop_Data_Entity_OrderItem", mappedBy="stockItem") */ protected $orderItem; ... }So there's my query: $q = $em->createQuery("select u from Shop_Data_Entity_StockItem u left // print 0 even there're Shop_Data_Entity_StockItem in database and There's echo $q->getSql(): SELECT s0_.ean AS ean0, s0_.title AS title1, s0_.description AS |
| Comments |
| Comment by Ondrej Sibrina [ 12/Apr/10 ] |
|
This test case is slightly different from example i wrote in description but shows same issue |
| Comment by Guilherme Blanco [ 12/Apr/10 ] |
|
Your report exposes exactly the issue pointed on DDC-349. We should take a look how to fix this without having to update ALL unit tests that takes advantage of inheritance. Also, the SQL spec requires that all joins need to be specified before write the ON keyword. Exception: [PDOException] SQLSTATE[HY000]: General error: 1 a JOIN clause is required before ON SELECT d0_.id AS id0, d0_.item AS item1 FROM DDC512Customer d0_ LEFT JOIN (DDC512OfferItem d1_ ON d0_.item = d1_.id INNER JOIN DDC512Item d2_ ON d1_.id = d2_.id) And in the situation of a inheritance: Exception: [PDOException] SQLSTATE[HY000]: General error: 1 a JOIN clause is required before ON SELECT o0_.id AS id0, o0_.name AS name1, o3_.id AS id2, o3_.name AS name3, o0_.discr AS discr4, o0_.mother_id AS mother_id5, o3_.discr AS discr6, o3_.mother_id AS mother_id7 FROM OJTIC_Pet o0_ LEFT JOIN OJTIC_Cat o1_ ON o0_.id = o1_.id LEFT JOIN OJTIC_Dog o2_ ON o0_.id = o2_.id INNER JOIN (OJTIC_Pet o3_ ON o0_.id = o3_.mother_id LEFT JOIN OJTIC_Cat o4_ ON o3_.id = o4_.id LEFT JOIN OJTIC_Dog o5_ ON o3_.id = o5_.id) WHERE o0_.name = 'Poofy' ORDER BY o3_.name ASC |
| Comment by Roman S. Borschel [ 13/Apr/10 ] |
|
I am aware of the problem and yes, nested joins for CTI can be a solution but its just 1 solution. The other one is to simply turn these CTI joins into left joins when they appear in the middle of a query (that is, not in the FROM clause). So, given a Class hierarchy like this: class Item class StockItem extends Item class OfferItem extends Item class OrderItem extends OfferItem StockItem <-onetoone-> OrderItem and a DQL like this: DQL: select s from StockItem s left join s.orderItem o ... We have 2 possible solutions. Nr. 1: Nested inner join SELECT ... FROM stockitem s1_
INNER JOIN item s0_ ON s1_.id = s0_.id
LEFT JOIN
(orderitem s2_ INNER JOIN offeritem s3_ ON s2_.id = s3_.id
INNER JOIN item s4_ ON s2_.id = s4_.id)
ON s1_.id = s2_.stockItem_id
Nr. 2: Just use left joins for parent tables for all CTI joins that are the result of a DQL join (This is what Hibernate does): SELECT ... FROM stockitem s1_ INNER JOIN item s0_ ON s1_.id = s0_.id LEFT JOIN orderitem s2_ ON s1_.id = s2_.stockItem_id LEFT JOIN offeritem s3_ ON s2_.id = s3_.id LEFT JOIN item s4_ ON s2_.id = s4_.id According to DDC-349, most databases seem to support nested inner joins (Nr. 1) but nevertheless its not in the ANSI standard I think, so I am not sure we can rely on it. The Hibernate solution seems simpler but I still wonder whether they perform differently (Usually, inner joins are more performant than outer joins), |
| Comment by Roman S. Borschel [ 15/Apr/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/01c2c06bbf529d89c9741ea97702359509ea230a using the "hibernate-way". Please note that you currently should not name join columns the same as entity fields. See |
[DDC-422] Unable to add entity in @ManyToMany association when owning entity is extended from another entity Created: 14/Mar/10 Updated: 18/Mar/10 Resolved: 18/Mar/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Ondrej Sibrina | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PHP 5.3.2 |
||
| Attachments: |
|
| Description |
|
Dear developers, I'm not sure if i extend entities in right way but i found different behaviour in extended entity which won't process add in @ManyToMany association. /** * @Entity * @HasLifecycleCallbacks * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"guest" = "Shop_Data_Entity_Guest", "customer" = "Shop_Data_Entity_Customer"}) */ class Shop_Data_Entity_Guest extends Shop_Data_Entity_Abstract { public function __construct() { /* call parent construct with all parameters */ call_user_func_array(array("parent","__construct"),func_get_args()); } } /** * @Entity * @HasLifecycleCallbacks */ class Shop_Data_Entity_Customer extends Shop_Data_Entity_Guest { /** * @ManyToMany(targetEntity="Shop_Data_Entity_Contact", cascade={"persist","remove"} ) * @JoinTable(name="Shop_Data_Entity_Customer__homes", * joinColumns={@JoinColumn(name="customer_id", referencedColumnName="id", onDelete="cascade" )}, * inverseJoinColumns={@JoinColumn(name="contact_id", referencedColumnName="id", onDelete="cascade" )} * ) */ public $homes; public function __construct() { /* call parent construct with all parameters */ call_user_func_array(array("parent","__construct"),func_get_args()); $this->homes = new Shop_Data_Collection_Standard(); // this class only extends ArrayCollection } } When i fire this code: $q = $em->createQuery("select c from Shop_Data_Entity_Customer c"); $q->setMaxResults(1); $customers = $q->getResult(); $contact = new Shop_Data_Entity_Contact(); $customers[0]->home->add($contact); $em->flush(); There's no change in database. /** @MappedSuperclass */ class Shop_Data_Entity_Guest extends Shop_Data_Entity_Abstract { public function __construct() { /* call parent construct with all parameters */ call_user_func_array(array("parent","__construct"),func_get_args()); } } It start work and every firing of my code add one contact and association to my database. It causes problem only when owning entity is quered from database at first. |
| Comments |
| Comment by Ondrej Sibrina [ 16/Mar/10 ] |
|
I tried to debug by myself and i found that on line 411 in UnitOfWork.php is on flush in first example $class->associationMappings == null. When i change Shop_Data_Entity_Guest to /** @MappedSuperclass */ i can find $class->associationMappings on same line with some elements. Hope it help to fix it Andy |
| Comment by Ondrej Sibrina [ 16/Mar/10 ] |
|
I tried to made patch by myself and it looks it start working. I'm not sure if this solution is proper. Andy from line 1731 of UnitOfWork.php if (isset($this->_identityMap[$class->name][$idHash])) { // $$class->rootEntityName to $class->name $entity = $this->_identityMap[$class->name][$idHash]; // $class->rootEntityName to $class->name $oid = spl_object_hash($entity); if ($entity instanceof Proxy && ! $entity->__isInitialized__) { $entity->__isInitialized__ = true; $overrideLocalValues = true; } else { $overrideLocalValues = isset($hints[Query::HINT_REFRESH]); } } else { //$entity = clone $class->prototype; $entity = new $className; $oid = spl_object_hash($entity); $this->_entityIdentifiers[$oid] = $id; $this->_entityStates[$oid] = self::STATE_MANAGED; $this->_originalEntityData[$oid] = $data; $this->_identityMap[$class->name][$idHash] = $entity; // $class->rootEntityName to $class->name |
| Comment by Ondrej Sibrina [ 16/Mar/10 ] |
|
To ensure i checkouted trunk version but it doesn't solve this problem. Andy |
| Comment by Ondrej Sibrina [ 16/Mar/10 ] |
|
After using my patch i can't do $em->remove properly any other patch? |
| Comment by Roman S. Borschel [ 18/Mar/10 ] |
|
This is fixed now in trunk. |
| Comment by Ondrej Sibrina [ 18/Mar/10 ] |
|
Thank you very much |
[DDC-2440] composer.json is wrong Created: 09/May/13 Updated: 09/May/13 Resolved: 09/May/13 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Richard Nicol | Assignee: | Marco Pivetta |
| Resolution: | Invalid | Votes: | 1 |
| Labels: | None | ||
| Description |
|
In composer.json for doctrine/doctrine-orm-module there is the following require: However "0.8.*" does not exist, it should be "0.8.x-dev" or "dev-master". The later would then use the branch alias. Either way this needs changing, because it's stopping the package from being installed or updated. |
| Comments |
| Comment by Benjamin Eberlei [ 09/May/13 ] |
|
Please open the ticket on the Doctrine ORM Module, this is the ORM bug tracker. |
| Comment by Richard Nicol [ 09/May/13 ] |
|
Sorry my mistake! I have opened an issue on github here: https://github.com/doctrine/DoctrineORMModule/issues/219 in case anyone ends up here. Cheers. |
| Comment by Marco Pivetta [ 09/May/13 ] |
|
DoctrineModule has a 0.8.x branch. Closing |
[DDC-802] Missing variable $name in XmlExporter Created: 14/Sep/10 Updated: 15/Sep/10 Resolved: 15/Sep/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | 2.0-RC1 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Martin Hasoň | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
At line 112 http://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php#L112 is required variable $name. This variable should be replaced by $unique['name']. And before this line should be test if(isset($unique['name'])). |
| Comments |
| Comment by Guilherme Blanco [ 15/Sep/10 ] |
|
On http://github.com/doctrine/doctrine2/commit/4845745337dbbed5eead25c3062a07103b38649f I fixed this issue. Thanks for the report. |
[DDC-1352] ErrorException: Undefined index in array Created: 30/Aug/11 Updated: 01/Sep/11 Resolved: 01/Sep/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Søren | Assignee: | Guilherme Blanco |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Windows 7, PHP 5.3.3 |
||
| Description |
|
The following query: Results in a PHP ErrorException in \Doctrine\ORM\Query\SqlWalker line 745: When I step through the execution, the array entry: $relation['mappedBy'] gets the following value: "Domain\Translation" in the scope where the error occurs. <entity name="Domain\Cuisine" table="Cuisine" repository-class="Infrastructure\Persistence\Doctrine\Repository\CuisineRepository"> <entity name="Domain\Translation" table="Translations"> <entity name="Domain\TranslationValue" table="TranslationValues"> <field name="value" type="string" column="Value" /> <many-to-one field="translation" target-entity="Domain\Translation"> <many-to-one field="language" target-entity="Domain\Language"> <entity name="Domain\Language" table="Languages" repository-class="\Infrastructure\Persistence\Doctrine\Repository\TranslationRepository"> |
| Comments |
| Comment by Guilherme Blanco [ 01/Sep/11 ] |
|
Your mapping information is wrong. Marking ticket as invalid. |
[DDC-2036] indexBy breaks cascade remove Created: 20/Sep/12 Updated: 03/Oct/12 Resolved: 03/Oct/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | James Bench | Assignee: | Fabio B. Silva |
| Resolution: | Can't Fix | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 12.04, PHP 5.3, 64 Bit, Symfony 2 |
||
| Attachments: |
|
| Description |
|
Adding the annotation indexBy causes the cascade annotation to be ignored: /**
Will cause an error when deleting the objects: An exception occurred while executing 'DELETE FROM location WHERE id = ?' with params {"1":19306}: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`symfony`.`location_data`, CONSTRAINT `FK_2DF7462364D218E` FOREIGN KEY (`location_id`) REFERENCES `location` (`id`)) Removing indexBy fixes the issue. My class structure is: Location has many LocationData The name field I am trying to index by comes from the AbstractData class. |
| Comments |
| Comment by Fabio B. Silva [ 23/Sep/12 ] |
|
Hi James Do you have a failing test case ? Thanks |
| Comment by James Bench [ 28/Sep/12 ] |
|
Entity exhibiting the behavior. |
| Comment by Fabio B. Silva [ 29/Sep/12 ] |
|
Hi James, Are you sure that you dont have more than one LocationData whith the same name ? When working with indexBy the index columns must be unique into the collection. If i'm wrong about it, please Thanks |
| Comment by James Bench [ 02/Oct/12 ] |
|
Hi Fabio, The test case uses a SQLite DB without any foreign keys so the issue wouldn't be apparent. How would I run the test against a MySQL db? I've also attached the SQL log for the script I'm running, it looks the same as the output from the testcase. Cheers,JB |
| Comment by James Bench [ 02/Oct/12 ] |
|
SQL Log from script causing errors. |
| Comment by Fabio B. Silva [ 02/Oct/12 ] |
|
Hi James, You must copy phpunit.xml.dist to phpunit.xml and change the database configurations. I have attached the mysql log, the test case works fine. |
| Comment by James Bench [ 02/Oct/12 ] |
|
It appears that it only attempts to delete 68 LocationData rows but in the database there are 76. |
| Comment by James Bench [ 02/Oct/12 ] |
|
Okay, I've found the reason for this; the name isn't unique, some are duplicated. Not sure whether you would consider this a bug. Thanks for your help. |
| Comment by Fabio B. Silva [ 02/Oct/12 ] |
|
No problem, you are welcome Actually isn't a bug, it is a documented behavior. "Fields that are used for the index by feature HAVE to be unique in the database." |
| Comment by Fabio B. Silva [ 03/Oct/12 ] |
|
Fields that are used for the index by feature HAVE to be unique in the database. |
[DDC-2285] Repeating the same query with different parameter value returns the same results Created: 08/Feb/13 Updated: 08/Feb/13 Resolved: 08/Feb/13 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, Mapping Drivers, ORM |
| Affects Version/s: | 2.3.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical |
| Reporter: | Mehdi Bakhtiari | Assignee: | Marco Pivetta |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 12.10, Zend Server CE |
||
| Description |
$activeAdsCustomers = \Ez\Registry::getDoctrineEntityManager()
->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )
->setParameter( "status", \Spot101\Model\Ad\Status::ACTIVE )
->getResult();
$inactiveAdsCustomers = \Ez\Registry::getDoctrineEntityManager()
->createQuery( "SELECT c, a FROM \Spot101\Model\Ad\Customer c JOIN c.ads a WHERE a.status = :status" )
->setParameter( "status", \Spot101\Model\Ad\Status::INACTIVE )
->getResult();
Having the code above I am getting the same results for $inactiveAdsCustomers as I get for $activeAdsCustomers. And when I try hydrating the results everything works so fine. Both queries look the same except the value provided for the "status" parameter. |
| Comments |
| Comment by Marco Pivetta [ 08/Feb/13 ] |
|
You are hydrating joined and filtered resultsets. You should never do this, as this will hydrate an invalid association into your objects. |
[DDC-2179] Transactions should sent in group not chunked Created: 29/Nov/12 Updated: 30/Nov/12 Resolved: 30/Nov/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.2, 2.3, Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Florin Patan | Assignee: | Marco Pivetta |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | unitofwork | ||
| Environment: |
MySQL 5.5 / Percona |
||
| Description |
|
In UnitOfWork::commit() it seems that a transaction is done like this:
The question would be, should my webserver have some issues with resources, wouldn't this part of the code be a pain for the DB? I don't know how mysql, for example, handles sending the transaction in chunks as opposed to sending it in 2/3 statements ( begin + ops and commit / + revert in case of failure) or in mySQL,l the transaction is evaluated on COMMIT statement only? If my assumption about how MySQL works, locking everything as soon as the statement is on the server, then shouldn't Doctrine use a internal buffer for sending transactions to the DB driver in order to avoid all sorts of problems that appear in high concurency scenarios? Best regards. |
| Comments |
| Comment by Marco Pivetta [ 30/Nov/12 ] |
|
Invalid IMO. This is an over-complication that (in such high load scenarios) is handled by clustering/load balancing. Not a problem of the ORM, since smashing all statements together will just make it impossible to trap any problems. |
| Comment by Marco Pivetta [ 30/Nov/12 ] |
|
This performance improvement has been discussed directly on IRC. The original problem is related to deadlocks and small transactions, which is not anyway solved by this issue. Otherwise, this improvement requires a PoC that shows that it is possible to have exceptions still showing the query that caused the failure. |
| Comment by Marco Pivetta [ 30/Nov/12 ] |
|
Sorry, was unclear. I basically mean that any approach squashing the queries into a single chunk sent to the DB should also allow us to get computed insert IDs and eventual exceptions should bubble up with the query that caused them. |
[DDC-263] YAML and XML Driver do not support cascading options "all", "detach". Also: Improvement of YAML Syntax (Patch attached) Created: 19/Jan/10 Updated: 22/Jan/10 Resolved: 22/Jan/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Christian Heinrich | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Hi there, I've attached a small patch which addresses the following issues: -> YAML did not support cascading options "all" (as described in documentation) and "detach" (as used in AssociationMapping class). The attached patch fixes that. -> XML does not support these things either, but the attached patch DOES NOT FIX THAT (see below). Also addressed: YAML had syntax like cascadeRemove, cascadePersist etc., but the documentation for the annotation driver uses only "persist, remove" etc. This patch changes the syntax to the following: cascade: [ persist, remove ] OR cascade:
(Both work!) It is now also possible to use cascade: [all] The YAML Driver was changed in that way that he must not know about the currently supported cascate actions. This has been pushed towards the AssociationMapping and I strongly believe that this is the right way. On the other hand, I did not change the XML Driver functionality. It does still know about the cascade actions and does most probably not support the detach and "all" actions. That should be fixed, but won't take too long. |
| Comments |
| Comment by Christian Heinrich [ 22/Jan/10 ] |
|
| Comment by Roman S. Borschel [ 22/Jan/10 ] |
|
That patch looks good but there seem to be tabs in your patches. Please make sure that you use "soft tabs" (4 spaces) in your editor. |
| Comment by Christian Heinrich [ 22/Jan/10 ] |
|
Resolved tab issue. |
| Comment by Roman S. Borschel [ 22/Jan/10 ] |
|
Patch applied. Thanks! So this will be included in todays ALPHA4 release. |
[DDC-193] Remove ClassMetadataInfo#inverseMappings Created: 06/Dec/09 Updated: 10/Apr/10 Resolved: 10/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers, ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
The ClassMetadataInfo#inverseMappings attribute is an unnecessary complication. The problem comes down to: "Given an association $assoc, how do I know if the association is bidirectional?". If $assoc is the inverse side ($assoc->isInverseSide()), its clear, its bidirectional. But if $assoc is the owning side, we dont know. if (isset($targetClass->inverseMappings[$assoc->sourceEntityName][$assoc->sourceFieldName])) { // Bi-directional } So we check whether the target class has an inverse mapping to the source class. This is quite cumbersome. Additionally, we're usually only interested in the sourceFieldName of the inverse association. Therefore, it would simplify internal code a lot if we simply introduced a "inversedBy" attribute on an association that is used on the owning side and that corresponds to "mappedBy" on the inverse side. Example: /** @Entity */
class A {
...
/**
* @OneToOne(targetEntity="Other", inversedBy="a")
* @JoinColumn(name="other_id", referencedColumnName="id")
*/
private $other;
...
}
...
/** @Entity */
class Other {
/** @OneToOne(targetEntity="A", mappedBy="other") */
private $a;
}
This breaks BC. However, I think this is really necessary as it simplifies and speeds up the code, together with removing the inverseMappings attribute altogether. So this should happen before beta. |
| Comments |
| Comment by Roman S. Borschel [ 31/Mar/10 ] |
|
Patch is ready and will be committed within the next week. |
[DDC-199] collection-valued, polymorphic fetch joins broken (hydration) Created: 07/Dec/09 Updated: 07/Dec/09 Resolved: 07/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Polymorphic fetch-joins of collections are currently broken in the ObjectHydrator. |
[DDC-187] JOIN fails with inherited entities Created: 02/Dec/09 Updated: 03/Dec/09 Resolved: 03/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
"Entity\User\AbstractUser" is a base entity for user records, "Entity\User\Person" extends AbstractUser (Single Table inheritance in this case). Now when I call this DQL: The ObjectHydrator fails in line 276 ("if ( ! $relation->isOneToOne()) {"...) with "PHP Fatal error: Call to a member function isOneToOne() on a non-object in .../lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php". It works when using the sub class for the query: |
| Comments |
| Comment by Nico Kaiser [ 02/Dec/09 ] |
|
It seems like ObjectHydrator::_hydrateRow tries to find a _ce entry for AbstractUser (but _ce only holds entries for Person)... |
| Comment by Roman S. Borschel [ 02/Dec/09 ] |
|
Does Setting use inheritance also? TopnewsSetting extends Setting? If so which inheritance type? |
| Comment by Roman S. Borschel [ 02/Dec/09 ] |
|
Can we see the classes and their mappings? AbstractUser, User, Setting and TopnewsSetting. Then I can set up a test to reproduce it. Thanks! |
| Comment by Nico Kaiser [ 02/Dec/09 ] |
|
Oh no I forgot to change TopnewsSetting to Setting in this report, there is no inheritance, just copy & paste bug. |
| Comment by Nico Kaiser [ 03/Dec/09 ] |
|
Here are the classes and example code: |
| Comment by Roman S. Borschel [ 03/Dec/09 ] |
|
Successfully reproduced in our test suite and working on it. |
| Comment by Roman S. Borschel [ 03/Dec/09 ] |
|
Should be fixed now. Thanks for reporting. |
[DDC-171] Cascade persist update foreign key for all unchanged entities Created: 23/Nov/09 Updated: 10/Dec/09 Resolved: 10/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Eric Durand-Tremblay | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Using cascade persist, linked entities get updated even if there is no change made. I get an update on the unchanged foreign key even if I don't modify UPDATE email SET client_id = ? WHERE id = ? $query = $qb->getQuery(); $client = $query->getSingleResult(); $em->flush(); |
| Comments |
| Comment by Roman S. Borschel [ 09/Dec/09 ] |
|
Can we see the query? I mean the DQL query! Thanks. |
| Comment by Roman S. Borschel [ 09/Dec/09 ] |
|
Nevermind. Got it reproduced. |
| Comment by Eric Durand-Tremblay [ 09/Dec/09 ] |
|
I tried with revision 6913 and I still reproduce the problem. Is there anyway I can use your UniTest framework, that way, I could check your test case and maybe suggest improvement. |
| Comment by Eric Durand-Tremblay [ 09/Dec/09 ] |
|
I managed to run the UnitTests. Do you have a test for this specific issue ? |
| Comment by Eric Durand-Tremblay [ 09/Dec/09 ] |
|
Here is my result for Doctrine/Tests/ORM/AllTests.php 1) testOptimisticTimestampSetsDefaultValue(Doctrine\Tests\ORM\Functional\Locking\OptimisticTest) strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead /home/eric/doctrine_trunk/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php:126 2) testOptimisticTimestampFailureThrowsException(Doctrine\Tests\ORM\Functional\Locking\OptimisticTest) DateTime::createFromFormat(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead /home/eric/doctrine_trunk/lib/Doctrine/DBAL/Types/DateTimeType.php:33 /home/eric/doctrine_trunk/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:225 /home/eric/doctrine_trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:239 /home/eric/doctrine_trunk/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php:112 /home/eric/doctrine_trunk/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php:102 /home/eric/doctrine_trunk/lib/Doctrine/ORM/AbstractQuery.php:511 /home/eric/doctrine_trunk/lib/Doctrine/ORM/AbstractQuery.php:387 /home/eric/doctrine_trunk/tests/Doctrine/Tests/ORM/Functional/Locking/OptimisticTest.php:136 3) testJoinedSubclassPersisterRequiresSpecificOrderOfMetadataReflFieldsArray(Doctrine\Tests\ORM\Functional\Ticket\DDC168Test) PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salary' cannot be null /home/eric/doctrine_trunk/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php:190 /home/eric/doctrine_trunk/lib/Doctrine/ORM/UnitOfWork.php:698 /home/eric/doctrine_trunk/lib/Doctrine/ORM/UnitOfWork.php:283 /home/eric/doctrine_trunk/lib/Doctrine/ORM/EntityManager.php:288 /home/eric/doctrine_trunk/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC168Test.php:34 |
| Comment by Roman S. Borschel [ 09/Dec/09 ] |
|
You need to fix your timezone settings but that is unrelated to this problem. To reproduce it, I added the following test temporarily to Doctrine\Tests\ORM\Functional\BasicFunctionalTest.php: public function testFlushDoesNotIssueUnnecessaryUpdates() { $user = new CmsUser; $user->name = 'Guilherme'; $user->username = 'gblanco'; $user->status = 'developer'; $address = new CmsAddress; $address->country = 'Germany'; $address->city = 'Berlin'; $address->zip = '12345'; $address->user = $user; $user->address = $address; $this->_em->persist($user); $this->_em->flush(); $this->_em->clear(); // show SQL from here on... $this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger); $query = $this->_em->createQuery('select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a'); echo "QUERY!".PHP_EOL; $user2 = $query->getSingleResult(); echo "FLUSH!".PHP_EOL; $this->_em->flush(); } However, since I did not really know how to check that, keeping this test in didnt make much sense. Can you try this test? Before my patch it issued an UPDATE query but not after my changes. It is pretty difficult to test this in an isolated manner. |
| Comment by Benjamin Eberlei [ 09/Dec/09 ] |
|
First two failures are your fault, you havent set the default timezone in php.ini The last failure is unrelated, its a benchmark for another bug. |
| Comment by Roman S. Borschel [ 09/Dec/09 ] |
|
OK. Latest trunk contains a test now that verifies that no SQL is executed on the flush. Can you please tell us how to modify it to reproduce the problem? Look into: Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php Last test method. |
| Comment by Eric Durand-Tremblay [ 09/Dec/09 ] |
|
Got it! Your fix worked on OneToOne relation but not OneToMany I did the same test using the CmsArticles entity and here is the result : SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3, c1_.id AS id4, c1_.topic AS topic5, c1_.text AS text6, c1_.user_id AS user_id7 FROM cms_users c0_ INNER JOIN cms_articles c1_ ON c0_.id = c1_.user_id
FLUSH!
UPDATE cms_users SET name = ? WHERE id = ?
array(2) {
[0]=>
string(6) "FooBar"
[1]=>
int(17)
}
UPDATE cms_articles SET user_id = ? WHERE id = ?
array(2) {
[0]=>
int(17)
[1]=>
int(2)
}
DONE!
DELETE FROM cms_users_groups
DELETE FROM cms_groups
DELETE FROM cms_addresses
DELETE FROM cms_phonenumbers
DELETE FROM cms_articles
DELETE FROM cms_users
|
| Comment by Eric Durand-Tremblay [ 09/Dec/09 ] |
|
Dont forget to add the cascade persist for the articles relation public function testFlushDoesNotIssueUnnecessaryUpdates() { $user = new CmsUser; $user->name = 'Guilherme'; $user->username = 'gblanco'; $user->status = 'developer'; $address = new CmsAddress; $address->country = 'Germany'; $address->city = 'Berlin'; $address->zip = '12345'; $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); $article->text = "Lorem ipsum dolor sunt."; $article->topic = "A Test Article!"; $article->setAuthor($user); $user->articles[] = $article; $address->user = $user; $user->address = $address; $this->_em->persist($user); $this->_em->flush(); $this->_em->clear(); // show SQL from here on... $this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger); //$query = $this->_em->createQuery('select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a'); $query = $this->_em->createQuery('select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a'); echo "QUERY!".PHP_EOL; $user2 = $query->getSingleResult(); $user2->name = "FooBar"; echo "FLUSH!".PHP_EOL; $this->_em->flush(); echo "DONE!".PHP_EOL; } |
| Comment by Roman S. Borschel [ 09/Dec/09 ] |
|
OK. I will look into this later or tomorrow. Thanks for your help. |
| Comment by Roman S. Borschel [ 10/Dec/09 ] |
|
Should be fixed now (second attempt) Can you check whether |
| Comment by Eric Durand-Tremblay [ 10/Dec/09 ] |
|
Yes, this is now fixed for me. Thank you for your great work !! |
[DDC-132] Subclass' columns missing from cached ClassMetadata::$resultColumnNames Created: 09/Nov/09 Updated: 09/Dec/09 Resolved: 09/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers, ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Reinier Kip | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
I have a Customer with class table inheritance mapping and some fields, and a subclass called SuperCustomer with two fields: bool `isSuper` and string `extra`. I found that when replacing the usual ArrayCache with a MemcacheCache, everything works fine on the first request, but notices occur on subsequent requests: Notice: Undefined index: isSuper in X:\...\Doctrine\ORM\Persisters\StandardEntityPersister.php on line 577 Inspection of ClassMetadata::$resultColumnNames on line 569 showed that the two fields `isSuper` and `extra` were (the only things) missing. The resulting object's `isSuper` and `extra` properties were empty. I have yet to find the cause of this, but maybe you have an idea. |
| Comments |
| Comment by Roman S. Borschel [ 09/Nov/09 ] |
|
This is indeed strange. My first guess was that the resultColumnNames get lost during serialization but the ClassMetadata#__sleep implementation seems to be correct in so far as it returns the resultColumnNames field as part of the fields to serialize. Let me know as soon as you have more information. Btw. Which metadata driver are you using? Annotations? |
| Comment by Reinier Kip [ 10/Nov/09 ] |
|
> My first guess was that the resultColumnNames get lost during serialization > Which metadata driver are you using? Annotations? I'll try to find where it goes wrong and let you know. |
| Comment by Reinier Kip [ 10/Nov/09 ] |
|
First request:
Second request:
Thought: the Customer's metadata is somehow changed after caching to cope with Customer's subclasses as well, but these changes are not in the cache. I don't have enough knowledge of Doctrine's internals, but you probably have a pretty good idea where this could happen. |
| Comment by Roman S. Borschel [ 10/Nov/09 ] |
|
Thanks for your detailed information. I think I know what the issue is now. May be non-trivial to fix. I will try to look into it as soon as I got some free time. |
| Comment by Jonathan H. Wage [ 11/Nov/09 ] |
|
Here is a patch which fixes the issue but through doing this roman and I realized another issue. |
| Comment by Roman S. Borschel [ 11/Nov/09 ] |
|
Scheduled for ALPHA4 as this may need some restructuring. |
| Comment by Roman S. Borschel [ 09/Dec/09 ] |
|
This should be fixed now in trunk. |
[DDC-119] Collection change tracking broken with NOTIFY policy Created: 06/Nov/09 Updated: 16/Jul/10 Resolved: 15/Jul/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.0-BETA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Looks like change tracking of collections together with the NOTIFY policy doesnt work well as collection updates are detected in _computeAssociationChanges. Perhaps the collection itself should inform the UnitOfWork directly? |
| Comments |
| Comment by Kawsar Saiyeed [ 16/Mar/10 ] |
|
Not sure if the issue is identical but seems at least related. Using NOTIFY change tracking with many-to-many bidirectional associations does not work. Objects added to the associations do not get persisted when calling EntityManager#flush. Tested on r7404. |
| Comment by Michael Zach [ 16/Jul/10 ] |
|
Dear Roman, the line # 456 in UnitOfWork.php seems wrong to me: $isChangeTrackingNotify = isset($this->entityChangeSets[$oid]);
Shouldn't this only be set if the entity has @ChangeTrackingPolicy("NOTIFY") *
set in his class docBlock? The current behaviour now is to assign $changeset if changes exists, leaving the NOTIFY tracking policy out: $changeSet = $isChangeTrackingNotify ? $this->entityChangeSets[$oid] : array();
Because of this change, all our unit tests involving saving of entites break (basically, the whole application), which implement @postUpdate for logging purposes logging an own computed changeset. |
| Comment by Roman S. Borschel [ 16/Jul/10 ] |
|
Hi, you're right, I did that naivly because I thought the only case where an entity would already have a changeset on flush is with the NOTIFY policy. I did not think of custom use cases like yours. It is fixed now in master. My apologies. However, this still means your approach would be broken if you would use the NOTIFY policy right? That sounds like maybe there is potential to improve the approach you're currently using. If you're missing anything in the API or implementation that forbids a different approach feel free to raise some new JIRA issues so we can possibly improve the situation. |
| Comment by Michael Zach [ 16/Jul/10 ] |
|
Thank you for fixing this real quick! Our current approach is to compute the changeset on @preUpdate and after a successful save write the changeset to the database in @postUpdate. This conflicted with the changes made, I will however look into it and see if it's feasible for us to implement another approach. Once again, thanks for your reply and fix. |
[DDC-116] array_combine error when using combined Primary Key Created: 05/Nov/09 Updated: 14/Jun/10 Resolved: 06/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
I use a combined Primary Key for a User's Phonenumber entity (to match our existing DB model). The key is combined from a "Type" field and a "userId" field that references the User table. To mark the (referenced!) userId field and the type field as PK, I need to add "userId" to the model (adding @Id to User does not work). This works well when generating Users and Phonenumbers - but the delete command breaks: PHP Warning: array_combine(): Both parameters should have an equal number of elements in ..../lib/Doctrine/ORM/Persisters/StandardEntityPersister.php on line 274 Entities: Test code: |
| Comments |
| Comment by Nico Kaiser [ 06/Nov/09 ] |
|
I attached a patch for Doctrine\Orm\Id\Assigned, there seems to be a runaway line which makes the class add each element twice... |
| Comment by Roman S. Borschel [ 06/Nov/09 ] |
|
Whoops. Thanks for finding this! Does it fix this issue? I will need to add a testcase to the suite. |
| Comment by Nico Kaiser [ 06/Nov/09 ] |
|
Does not entirely fix it: if the $value is empty, too few elements are added again. |
| Comment by Roman S. Borschel [ 06/Nov/09 ] |
|
I think the isset() is correct. That way the $identifier array remains empty if the PK is null and later if ( ! $identifier) evaluates to false on the empty array and raises the exception. If we remove the isset() we would "accept" PKs with null values. But it might be better to do: if (!isset($value)) { throw ORMException::entityMissingAssignedId($entity); } else { $identifier[] = $value; } |
| Comment by Roman S. Borschel [ 06/Nov/09 ] |
|
I will fix this and add some new tests for it. |
| Comment by Roman S. Borschel [ 06/Nov/09 ] |
|
Should be fixed now. |
[DDC-113] Cascaded persist avoids LifecycleCallbacks Created: 04/Nov/09 Updated: 18/Dec/09 Resolved: 18/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
When an Entity is created by 'cascade= {"persist"}', its LifecycleCallbacks (e.g. "PrePersist"!) are not invoked. When it is persisted explicitly, everything workes fine and the events are called... |
| Comments |
| Comment by Benjamin Eberlei [ 11/Dec/09 ] |
|
Works for me on trunk, added test-case that proves it (Doctrine\Tests\ORM\Functional\LifecycleCallbackTest::testCascadedEntitiesCallsPrePersist()) |
| Comment by Nico Kaiser [ 14/Dec/09 ] |
|
There is still an issue. You can reproduce it if you change the test case slightly to this: /**
* @group DDC-113
*/
public function testCascadedEntitiesCallsPrePersist()
{
$e1 = new LifecycleCallbackTestEntity;
$e2 = new LifecycleCallbackTestEntity;
$c = new LifecycleCallbackCascader();
$this->_em->persist($c);
$c->entities[] = $e1;
$c->entities[] = $e2;
//$this->_em->persist($c);
$this->_em->flush();
$this->assertTrue($e1->prePersistCallbackInvoked);
$this->assertTrue($e2->prePersistCallbackInvoked);
}
The difference to the existing (and indeed working) test case is that the Cascader entity is persisted before the collection entries are added. |
| Comment by Benjamin Eberlei [ 14/Dec/09 ] |
|
That is valid behaviour according to the lifecycle of an entity, persist gets cascaded right and only when ->persist() is called. In the case you show, the two entities are also not persisted, because the cascade was already executed. |
| Comment by Nico Kaiser [ 14/Dec/09 ] |
|
From a technical point of view this is ok - but from an intuitive point of view I would think I can use persist whereever I want. So I can create an entity, persist it (so it gets written to the DB), make changes to it (like adding entities to its collection) and getting its saved (and the collection entities persisted) when I call flush(). So I suspect lifecycle events to be called whenever an entity is persisted. And in this case LifecycleCallbackTestEntity's are persisted automatically by flush() (and this is after the Cascader is persisted!), so lifecycle events should fire here. |
| Comment by Roman S. Borschel [ 17/Dec/09 ] |
|
I have a fix for this ready, however, I want to look into something else before committing. I'll address this over the weekend. |
| Comment by Roman S. Borschel [ 18/Dec/09 ] |
|
Should be fixed now. |
[DDC-74] Updates get lost when Lifecycle Events (@PreUpdate) are invoked Created: 29/Oct/09 Updated: 13/Nov/09 Resolved: 13/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
|
When Lifecycle Events are invoked on entity update (@PreUpdate), the entity is not updated properly in the database. This code creates a User object, sets its name to "Bob" and its value to empty, then updates the object and updates the name to "Alice".
However, when the User class has a @PreUpdate event that e.g. sets the value to "Hello World", the name change gets lost and only the value is updated by the second flush() call. This is a critical bug which prevents creation of entities that simulate the "Timestampable" behaviour of Doctrine 1.x... |
| Comments |
| Comment by Benjamin Eberlei [ 02/Nov/09 ] |
|
I think this might be a hen-egg problem. @PreUpdate is only invoked after it is calculated that a change occured on all those entities that have updates. After a change in @PreUpdate events there would have to be another calculation of changes on all those entities, which would probably mean a significant performance hit. |
| Comment by Eric Durand-Tremblay [ 13/Nov/09 ] |
|
I may not know all the consequences of this, but I think I have a fix for this bug. In the class ORM\UnitOfWork As I understand it, computeSingleEntityChangeSet() is called to update the changeset and _originalEntityData is set to the current values. But, I see that the old changes are lost. If i modify the function computeSingleEntityChangeSet to merge the changeset, it works. At line 656 replace $this->_entityChangeSets[$oid] = $changeSet;
By : if($this->_entityChangeSets[$oid]){ $this->_entityChangeSets[$oid] += $changeSet; } else { $this->_entityChangeSets[$oid] = $changeSet; } Here is my test case : $qb = new \Doctrine\ORM\QueryBuilder($em);
$qb->select('fna')
->from('Entity\FNA', 'fna')
->andwhere($qb->expr()->eq('fna.id', ':fna_id'));
$qb->setParameter('fna_id', 1);
$query = $qb->getQuery();
$fna = $query->getSingleResult();
$fna->setStatus('COMPLETED');
$em->persist($fna);
$em->flush();
AND The preUdate : /** * @PreUpdate */ public function onPreUpdate($args=false) { $this->modified_at = new \DateTime(); } |
| Comment by Roman S. Borschel [ 13/Nov/09 ] |
|
Indeed this looks like a good fix except that the addition has to be the other way around so that when the same field is changed twice, first before the flush and then in a lifecycle callback/event the change from the callback prevails. I will work on this and write a test for it. Thanks Eric. |
| Comment by Roman S. Borschel [ 13/Nov/09 ] |
|
Fixed now. Thanks Nico for reporting and thanks Eric for the suggestion! |
[DDC-61] OneToOne relation with an entity using Class Table Inheritance fails Created: 27/Oct/09 Updated: 04/Nov/09 Resolved: 03/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ville Väänänen | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
The bug occurs when there's a lazy bidirectional one-to-one relation where the inverse side only specifies the root entity. In this case, the final type of the target-entity is not resolved correctly. See the attached file for a failing test case. |
| Comments |
| Comment by Ville Väänänen [ 27/Oct/09 ] |
|
The situation is actually worse if the relation is eager. In that case not only is the classname incorrectly resolved, but if the root-entity is an abstract class, the execution ends up in a fatal error. It would seem to me that there are two ways to deal with the described problem: 1. join all the tables that contain the discriminator-fields, so that the correct subclasses can be inferred |
| Comment by Ville Väänänen [ 27/Oct/09 ] |
|
A fix to the patch. Use the newer attachment. |
| Comment by Ville Väänänen [ 02/Nov/09 ] |
|
I have patches for both of the options above. Should this be a configuration option? As it stands now, OneToMany and ManyToMany relationships enjoy the advantage of having the Collection in between the target and source entities. We could even use a hybrid approach, where a general proxy-object is created only when the object type cannot be inferred without joins. |
| Comment by Roman S. Borschel [ 02/Nov/09 ] |
|
It should of course be Nr. 1. The discriminator column is always stored in the topmost (root) table and tables of base classes must be joined, always. If this is not the case this is a bug. Can you show your patch? |
| Comment by Ville Väänänen [ 03/Nov/09 ] |
|
It would seem to me that this would cause an inconsistency in how similar associations with different kinds of entities are treated. From |
| Comment by Ville Väänänen [ 03/Nov/09 ] |
|
Describing the changes StandardEntityPersister.php.diff:
This selects the existence/discrimator-column information when an entity is queried using EntityManager->find, it's doesn't help if one is using a DQL query. |
| Comment by Roman S. Borschel [ 03/Nov/09 ] |
|
I understand now what the problem is. Its tricky. Your testcase however has a wrong mapping. The way you mapped it, any event that is fetched of a company will automatically be the main event It will probably be treated similar to inverse sides of one-one. That means, when a one-one associations references a target entity that is a base type (not an outermost type, that means there are still possible subtypes), whether the association is the owning side or not it must be eagerly fetched. |
| Comment by Ville Väänänen [ 04/Nov/09 ] |
|
Okay, so not allowing lazy-loading in this case at all. Why is this? As I stated earlier there are at least to ways to solve this without resorting to eager-loading. If using class-table inheritance means forgetting about lazy-load, to me at least it's a huge disadvantage and would be a deal breaker in using this inheritance-type. The problem with eager-load is not the first fetch that follows, but the uncertainty of how many fetches are going to follow in total. If the target-entity is the tip of a huge object-hierarchy full of entities using class-table inheritance, the current strategy is unusable. Having a couple of extra tables joined is nothing compared to the snowball that eager-fetching might get rolling. |
| Comment by Roman S. Borschel [ 04/Nov/09 ] |
|
Well, option Nr.1 is too complicated and can lead to lots of new issues. You can not always join arbitrary tables, not when it comes to DQL where it alters the overall result. The situation is much more complex than it might look to you right now. Nr.2 is no option at all because such a proxy approach does not even hold for instanceof checks. An absolute no-go. What it does now is the best thing from my point of view. If performance becomes an issue you can always improve upon that by eager fetching with DQL. Also, you did not yet understand how it works. The eager load does not happen always with class table inheritance, only when the target entity is a base type. If it is a subtype that does not have any further subtypes, then a proxy can be used without fear. Same goes for single table inheritance. |
| Comment by Roman S. Borschel [ 04/Nov/09 ] |
|
If you still feel this is too bad open a new issue as "improvement" and move any old/new patches you have there. There would need to be much more tests for such a change. Also you did not mention whether your patch actually passes all existing unit tests. |
| Comment by Ville Väänänen [ 04/Nov/09 ] |
|
Sure I understood how it works. But to me one of the biggest advantages of class-table inheritance is exactly that the parent doesn't have to know the final type., and so in the configuration the association is pointed to the base-type. Yes, I accept that the issue might be way too complicated in the DQL case. Option number two can be improved if the parent model that might have these general proxies invokes a load in it's getters. Exactly the way the generated proxies work now. Of course, this means that the models need to be aware of the possible proxies. It's not perfect, but maybe it could be an option? |
| Comment by Roman S. Borschel [ 04/Nov/09 ] |
|
Please open a new issue, I think this has potential as an improvement that can complement the current behavior. What I mean is: for normal find/load ... operations that are not triggered by DQL we can probably do the join and in the case of DQL the current behavior is used, if you want to avoid the extra query in that case its as simple as adding the join to DQL. So I think the approaches can be complementary. |
| Comment by Ville Väänänen [ 04/Nov/09 ] |
|
Sure like the sound of that! I will be very happy to open this as an improvement. Thanks for your patience |
[DDC-41] Getting error with lazy loading via createQuery() followed by $em->flush() Created: 10/Oct/09 Updated: 12/Oct/09 Resolved: 12/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nichlas Löfdahl | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine2-trunk, Postgresql, Lazy loading |
||
| Description |
|
Simple O-O relationship between \Entities\User and \Entities\Feed. Seems like there's a problem with not-yet lazy-loaded proxies and $em->flush(). "Entities/User.php" <?php namespace Entities; /** @Entity @Table(name="users_debug") */ class User { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** * @OneToOne(targetEntity="Feed", mappedBy="User", cascade={"persist"}) */ private $Feed; public function getID() { return $this->id; } public function getFeed() { return $this->Feed; } public function setFeed($feed) { $this->Feed = $feed; } } ?> "Entities/Feed.php" <?php namespace Entities; /** * @Entity @Table(name="feeds_debug") */ class Feed { /** * @Id @Column(type="integer") * @GeneratedValue(strategy="AUTO", allocationSize=1) */ private $id; /** * @OneToOne(targetEntity="User", cascade={"persist"}) * @JoinColumn(name="user_id", referencedColumnName="id") */ private $User; function setID($value) { $this->id = $value; } function getID() { return $this->id; } function getUser() { return $this->User; } function setUser($user) { $this->User = $user; } } ?> Table-data users_debug: id 361 feeds_debug: id | user_id 461 | 361 Code: $user = $em->createQuery("SELECT u FROM Entities\User u WHERE u.id = 361")->getSingleResult(); print $user->getID(); // 361 // uncomment line below and it works // print $user->getFeed()->getID(); $em->flush(); Error: PostgreSQL log: |
| Comments |
| Comment by Roman S. Borschel [ 12/Oct/09 ] |
|
Strange, all the warnings and errors and the stack trace rather indicate that the associated value is NULL and not a (not initialized) proxy object. I'm working on this and already found an issue to address but I'm still unable to exactly reproduce this. Will keep you updated. If you have any further information, please let me know. |
| Comment by Roman S. Borschel [ 12/Oct/09 ] |
|
OK, managed to reproduce this. Working on it. |
| Comment by Roman S. Borschel [ 12/Oct/09 ] |
|
This should now be fixed but you need to manually delete your proxy classes so that they're regenerated. More improvements to the proxy classes and CLI tasks for (re)generating proxy classes will follow. |
[DDC-34] schema-tool --create tries to create duplicate associations and exits with exception Created: 07/Oct/09 Updated: 07/Oct/09 Resolved: 07/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Ismo Toijala | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
HEAD |
||
| Description |
|
I'm getting the error SchemaTool:Duplicate field mapping () when trying to create my database schema. I am pretty sure this worked before. The error occurs on a field defined in a mapped superclass on the first entity that extends this class on the first association. My entity classes: namespace Model; use \Model\User\User; use \DateTime; /** * @MappedSuperclass */ abstract class Blameable { /** * * @var DateTime * * @Column(type="datetime", name="date_created") */ protected $dateCreated; /** * * @var User * * @OneToOne(targetEntity="Model\User\User") * @JoinColumn(name="creator_id", referencedColumnName="id", nullable="true") */ protected $creator; /** * * @var DateTime * * @Column(type="datetime", name="date_updated", nullable="true") */ protected $dateUpdated; /** * * @var User * * @OneToOne(targetEntity="Model\User\User") * @JoinColumn(name="updater_id", referencedColumnName="id", nullable="true") */ protected $updater; /** * * @var DateTime * * @Column(type="datetime", name="date_deleted", nullable="true") */ protected $dateDeleted; /** * * @var User * * @OneToOne(targetEntity="Model\User\User") * @JoinColumn(name="deleter_id", referencedColumnName="id", nullable="true") */ protected $deleter; } namespace Model\User; use \Zend_Validate_Alnum; use \Zend_Validate_StringLength; use \Zend_Validate_Alpha; use \Zend_Validate_EmailAddress; use \Zend_Registry; use \Model\Blameable; use \Model\ConstraintException; use \Itoijala_Singletons; use \Zend_Auth; use \Itoijala_Password_Hash; /** * * * @Entity @Table(name="user_users") */ class User extends Blameable { /** * * @var int * * @Id @Column(type="integer", name="id") * @GeneratedValue(strategy="AUTO") */ private $id; /** * * @var string * * @Column(type="string", length="20", name="username") */ private $username; /** * * @var string * * @Column(type="string", length="20", name="first_name") */ private $firstName; /** * * @var string * * @Column(type="string", length="20", name="last_name") */ private $lastName; /** * * @var string * * @Column(type="string", length="255", name="email") */ private $email; /** * * @var string * * @Column(type="string", length="20", name="signature") */ private $signature; /** * * @var string * * @Column(type="string", length="128", name="password") */ private $password; /** * * @var string * * @Column(type="string", length="255", name="role") */ private $role; /** * * @var string * * @Column(type="string", length="32", name="session_id", nullable="true") */ private $sessionId; /** * * @var bool * * @Column(type="boolean", name="unlocked") */ private $unlocked; } namespace Model\Article; use \Closure; use \Model\Blameable; use \Doctrine\Common\Collections\Collection; use \Doctrine\ommon\Collections\ArrayCollection; use \Model\User\User; use \Model\Gallery\Gallery; use \Model\ConstraintException; use \Zend_Validate_StringLength; /** * @Entity @Table(name="article_articles") */ class Article extends Blameable { /** * * @var int * * @Id @Column(type="integer", name="id") * @GeneratedValue(strategy="AUTO") */ private $id; /** * * @var Category * * @ManyToOne(targetEntity="Model\Article\Category") * @JoinColumn(name="category_id", referencedColumnName="id") */ private $category; /** * * @var string * * @Column(type="string", length="255", name="name") */ private $name; /** * * @var string * * @Column(type="text", name="description") */ private $description; /** * * @var string * * @Column(type="string", length="255", name="thumbnail") */ private $thumbnail; /** * * @var string * * @Column(type="text", name="content") */ private $content; /** * * @var int * * @Column(type="integer", name="views") */ private $views; /** * * @var bool * * @Column(type="boolean", name="news") */ private $news; /** * * @var bool * * @Column(type="boolean", name="unlocked") */ private $unlocked; /** * * @var Collection * * @ManyToMany(targetEntity="Model\Gallery\Gallery") * @JoinTable(name="article_article_galleries", * joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="gallery_id", referencedColumnName="id")}) */ private $galleries; /** * * @var Collection * * @ManyToMany(targetEntity="Model\User\User") * @JoinTable(name="article_article_authors", * joinColumns={@JoinColumn(name="article_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="user_id", referencedColumnName="id")}) */ private $authors; /** * * @var Collection * * @OneToMany(targetEntity="Model\Article\Attachment", mappedBy="article") */ private $attachments; } |
[DDC-32] EntityManager#getReference broken Created: 07/Oct/09 Updated: 07/Oct/09 Resolved: 07/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
. |
[DDC-33] Remove allowPartialObjects option. Created: 07/Oct/09 Updated: 15/Oct/09 Resolved: 15/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA2 |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Task | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I think this option will cause unnecessary confusion. The best solution is to always disallow partial objects, yet you can force partial objects on individual object queries to increase performance if necessary. This is much simpler for the user than to remember all the details of how the current option affects certain behavior. Also, with the current default behavior of partial objects everywhere, some standard operations can unexpectedly not work, like adding an object to a collection of a managed object (but the collection itself was not fetched yet). As a result the collection will not be wrapped by doctrine with a PersistentCollection and modifications are lost. I will do this myself and I think this can even be done with full backwards compatibility (though its not strictly necessary since we're still in alpha). This should be done before entering beta. |
[DDC-26] Add support for subdirectories in classdir when using schema-tool --create Created: 01/Oct/09 Updated: 05/Oct/09 Resolved: 05/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA2 |
| Security Level: | All |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Ismo Toijala | Assignee: | Jonathan H. Wage |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Currently when using schema-tool --create, all entity classes have to be in one directory. Subdirectories are not supported and result in errors. The iterator tries to require the subdirectories. This makes it impossible to use schema-tool --create to create the database for models that use namespaces and follow Doctrine rules for placing the files in subdirectories. The schema-tool should iterate through all of the subdirectories of the classdir to find all of the entity classes. It should also not try to require() any directories. |
| Comments |
| Comment by Roman S. Borschel [ 01/Oct/09 ] |
|
Jon, I remember you mentioning this issue already. Did you fix it already? |
| Comment by Jonathan H. Wage [ 01/Oct/09 ] |
|
No but I will fix it. The problem exists in Doctrine\ORM\Tools\Export\ClassMetadataExporter as well. |
| Comment by Guilherme Blanco [ 03/Oct/09 ] |
|
We should make is an option, not recursive all the time.... maybe include as an optional parameter --recursive I'll check it out the issue and will come with a solution later today. |
[DDC-21] Already fetched associations should not be overriden by subsequent queries. Created: 25/Sep/09 Updated: 09/Oct/09 Resolved: 09/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
The discussion about this was brought up by Entities and their associations that are already in-memory should only be refreshed if this is done explicitly either through EntityManager#refresh($entity) or through using the Query::HINT_REFRESH query hint on any query. |
| Comments |
| Comment by Roman S. Borschel [ 25/Sep/09 ] |
|
This behavior is already correct for single-valued associations but not for collections. Needs to be fixed in ObjectHydrator. |
[DDC-22] EntityManager#refresh() should also refresh associations. Created: 25/Sep/09 Updated: 28/Oct/09 Resolved: 28/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-ALPHA3 |
| Security Level: | All |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Initially this issue was brought up by 1) For the state of the entity that is refreshed itself this is self-explanatory (simple select on the primary table, this is what already works). 2) For single-valued associations the proper query depends on whether the entity being refreshed represents the owning side or the inverse side of the association. If it is the inverse side, a simple query like this should do: select addresses.id, ... from addresses where addresses.user_id=? If it is the owning side, a join may be required: select addresses.id, ... from addresses inner join users on addresses.id = users.address_id where users.id=? 3) For one-to-many collections, a simple select on the target entity table, similar to the following should do: select .... from phonenumbers ... where phonenumbers.user_id=? For many-to-many collections a similar select that joins over the join table is required. An clever way for collections might be to not trigger this SQL immediately on refresh() but to simply mark the collection as uninitialized again so that the first access would trigger the reload, similar to a lazy-load. Note that the collection itself is refreshed, not the state of the entities contained therein. |
[DDC-604] array_merge in Query::_doExecute causes parameter reordering Created: 20/May/10 Updated: 07/Jun/10 Resolved: 07/Jun/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | David Abdemoulaie | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Hi all, foreach ($this->_params as $key => $value) {
if ( ! isset($paramMappings[$key])) {
throw QueryException::unknownParameter($key);
}
if (isset($this->_paramTypes[$key])) {
foreach ($paramMappings[$key] as $position) {
$types[$position] = $this->_paramTypes[$key];
}
}
if (is_object($value) &&
$this->_em->getMetadataFactory()->hasMetadataFor(get_class($value))) {
$values =
$this->_em->getUnitOfWork()->getEntityIdentifier($value);
$sqlPositions = $paramMappings[$key];
$sqlParams = array_merge($sqlParams,
array_combine((array)$sqlPositions, $values));
} else {
foreach ($paramMappings[$key] as $position) {
$sqlParams[$position] = $value;
}
}
}
When constructing the $sqlParams array, array_merge is used for params wich Edit a fail case : SQL (for postgres): CREATE TABLE first_class
(
id serial NOT NULL,
"text" character varying,
second_class_id integer,
CONSTRAINT first_class_pkey PRIMARY KEY (id),
CONSTRAINT first_class_second_class_id_fkey FOREIGN KEY (second_class_id)
REFERENCES second_class (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
CREATE TABLE second_class
(
id serial NOT NULL,
CONSTRAINT second_class_pkey PRIMARY KEY (id)
);
INSERT INTO second_class(
id)
VALUES (1);
FirstClass.php /**
* @Entity
* @Table(name="first_class")
*/
class FirstClass {
/**
* @Id
* @Column(name="id",type="integer")
*/
private $id;
/** @Column(name="text",type="string") */
private $text;
/**
* @OneToOne(targetEntity="SecondClass")
* @JoinColumn(name="second_class_id", referencedColumnName="id")
*/
private $secondClassInstance;
}
SecondClass.php /**
* @Entity
* @Table(name="second_class")
*/
class SecondClass {
/**
* @Id
* @Column(name="id",type="integer")
*/
private $id;
}
Test Case : $secondClassInstance = $doctrineEntityManager->find('SecondClass',1);
$query = $doctrineEntityManager->createQuery("SELECT f FROM FirstClass f WHERE f.text = :text AND f.secondClassInstance = :instance")->setParameters(array('instance'=>$secondClassInstance,'text'=>'Un texte en francais',));
echo $query->getSQL();
$query->execute();
When you execute this query it fails. When printing the $sqlParams variable from _doExecute you can see the folowing : |
| Comments |
| Comment by David Abdemoulaie [ 20/May/10 ] |
|
Brought Paul's changes over to doctrine/orm in branch |
| Comment by Paul Fariello [ 22/May/10 ] |
|
I've just added the fail case |
[DDC-599] Inheritance breaks cascading Created: 18/May/10 Updated: 07/Jun/10 Resolved: 07/Jun/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
When using inheritance, cascade= {"delete"} does not work anymore:This example creates three Entities: - Item - SubItem (extends Item) - Child The Item has a OneToMany association with Child with cascade={"delete"} , so if an Item is deleted, its Children are deleted too. However this does not work, the cascade is ignored when the Item is deleted. Without inheritance (e.g. only Item with Children) it works perfectly. |
| Comments |
| Comment by Nico Kaiser [ 18/May/10 ] |
|
By the way, this cannot be reproduced with the included testcases (no DB connection). So the problem may be between the ORM and the DBAL... |
| Comment by Roman S. Borschel [ 18/May/10 ] |
|
Do you get any error message? exception? stack trace? |
| Comment by Nico Kaiser [ 18/May/10 ] |
|
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`kaiser_sandbox`.`Child`, CONSTRAINT `Child_ibfk_1` FOREIGN KEY (`parentId`) REFERENCES `Item` (`id`))' in /home/kaiser/doctrine/doctrine/lib/Doctrine/DBAL/Connection.php:637 |
| Comment by Roman S. Borschel [ 19/May/10 ] |
|
Scheduled for beta2 but not sure we can make it, might end up on beta3. Increasing priority though as this seems to be a bug and these have priority. |
| Comment by Benjamin Eberlei [ 06/Jun/10 ] |
|
Attached a test-case that verifies this bug exists. Problem is the CommitOrderNodeCalculator not knowing about sub-class dependencies. |
[DDC-593] Subquery parenthesis omitted in generated SQL Created: 16/May/10 Updated: 16/May/10 Resolved: 16/May/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | John Kleijn | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
$dQuery = $this->_em->createQuery( As you see this includes brackets around the subqueries. var_dump($dQuery->getSQL()); SELECT s0_.level AS level0, s0_.lft AS lft1, s0_.rgt AS rgt2, s0_.id AS id3, s0_.name AS name4, s0_.description AS description5 FROM system_group s0_ WHERE (s0_.lft >= SELECT s1_.lft FROM system_group s1_ WHERE s1_.name = ?) AND (s0_.rgt <= SELECT s2_.rgt FROM system_group s2_ WHERE s2_.name = ?) Brackets gone, resulting in: 'PDOException' with message '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 'SELECT s1_.lft FROM system_group s1_ WHERE s1_.name = 'root') AND (s0_.rgt <= SE' at line 1' in /usr/share/php/lib/Doctrine/DBAL/Connection.php:566 Brackets added and executed against database SELECT s0_.level AS level0, s0_.lft AS lft1, s0_.rgt AS rgt2, s0_.id AS id3, s0_.name AS name4, s0_.description AS description5 FROM system_group s0_ WHERE (s0_.lft >= (SELECT s1_.lft FROM system_group s1_ WHERE s1_.name = "root")) AND (s0_.rgt <= (SELECT s2_.rgt FROM system_group s2_ WHERE s2_.name = "root")) Works (MySQL). |
| Comments |
| Comment by John Kleijn [ 16/May/10 ] |
|
Double brackets in the DQL results in "exception 'Doctrine\ORM\Query\QueryException' with message '[Syntax Error] line 0, col 62: Error: Expected Literal, got 'SELECT'' in /usr/share/php/lib/Doctrine/ORM/Query/QueryException.php:42 |
| Comment by Roman S. Borschel [ 16/May/10 ] |
|
This might be caused by recent AST optimizations and thus I suspect this to be a regression. |
| Comment by John Kleijn [ 16/May/10 ] |
|
Is there a workaround (other than not using a subquery)? |
| Comment by Roman S. Borschel [ 16/May/10 ] |
|
Well, a workaround for any DQL issues that is always available is a NativeQuery (createNativeQuery). In essence, a DQL query is just a high-level abstraction for a native SQL query + a ResultSetMapping. http://www.doctrine-project.org/projects/orm/2.0/docs/reference/native-sql/en#native-sql The resulting objects from a native query are still fully managed and all, so its just a difference in query abstraction. Nevertheless, this should be fixed soon. |
| Comment by Roman S. Borschel [ 16/May/10 ] |
|
Reproduced this successfully and already have a potential fix. Might not be a regression after all but a bug nevertheless. |
| Comment by Roman S. Borschel [ 16/May/10 ] |
|
Should be fixed now in HEAD (doctrine2/master). |
[DDC-576] New entities must have primary key values right after flushing with IDENTITY strategy Created: 07/May/10 Updated: 08/May/10 Resolved: 08/May/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Václav Novotný | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
PostgreSQL 8.4.3, Ubuntu 10.04 |
||
| Attachments: |
|
| Description |
|
After insertion of some new entity the primary key must be set. Example code is attached above. |
| Comments |
| Comment by Roman S. Borschel [ 07/May/10 ] |
|
I think I reproduced this already. Seems to be related to PostgreSQL + IDENTITY only. The SequenceIdentityGenerator must be used but apparently it is not used. Thanks for the report. Will keep you updated. ps. The standalone reproduce scripts are good. Thanks for that! If you are interested it would be even better if the test code would be provided as a unit test or with some additional comments and/or assertions about what the desired behavior is or where the supposedly wrong behavior is (even if it is very obvious, like in this issue). |
[DDC-561] Metadata caching broken due to incomplete __sleep functions Created: 30/Apr/10 Updated: 30/Apr/10 Resolved: 30/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
When using a persistent Metadata cache, the serialized ClassMetadata objects are not complete. This leads to very strange behavior since not all Metadata is loaded in the next request (which uses cached Metadata). The problem is that the __sleep methods of Doctrine\ORM\Mapping\AssociationMapping and Doctrine\ORM\Mapping\ClassMetadata are note complete (missing "namespace", "fetchMode" properties). |
| Comments |
| Comment by Nico Kaiser [ 30/Apr/10 ] |
|
This patch fixes the issue for AssociationMapping and ClassMetadata. I'm not sure if there are more properties missing... |
| Comment by Roman S. Borschel [ 30/Apr/10 ] |
|
Ouch, bad oversight. Sorry for that. We do actually have tests for serializing and unserializing the metadata, obviously not enough... will fix it asap. |
| Comment by Roman S. Borschel [ 30/Apr/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/db2be55e27c87fa513073b2bf44456f1d1423582 . Thanks for your help. |
| Comment by Benjamin Eberlei [ 30/Apr/10 ] |
|
Should we re-release Beta1? This is pretty serious and might annoy people |
| Comment by Roman S. Borschel [ 30/Apr/10 ] |
|
Hehe, no its fine. You can easily patch it manually if needed and beta2 is only a few weeks away. |
| Comment by Roman S. Borschel [ 30/Apr/10 ] |
|
And you can just use HEAD and not the tag, of course |
[DDC-531] Collections broken in self-referenced Entities Created: 20/Apr/10 Updated: 23/May/10 Resolved: 23/May/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||||
| Sub-Tasks: |
|
| Description |
|
When dealing with parent / children entities, the UnitOfWork does not always hydrate all data correctly. This example generates Group1 and its child Group2. Then Clears the Entity Manager, loads Group2 (so it is in the EM), loads Group1 and then the children of Group1 (Group2 is the child of Group1). Warning: Invalid argument supplied for foreach() in /Users/nico/Projects/test/test.php on line 20 When calling Debug::dump($group4), I get this: object(stdClass)#56 (2) {
["__CLASS__"]=>
string(26) "Proxies\EntitiesGroupProxy"
["id"]=>
string(1) "1"
}
test.php Group entity: |
| Comments |
| Comment by Nico Kaiser [ 20/Apr/10 ] |
|
If I clear the Entity Manager between lines 17 and 18, it works... Seems like the previously loaded Group is reused (which is perfectly fine), but its associations (or at least its self-referenced associations) are not loaded (neither proxies are generated)... |
| Comment by Roman S. Borschel [ 23/Apr/10 ] |
|
Thanks for reporting. I will take a look as soon as I find the time. |
| Comment by Nico Kaiser [ 23/Apr/10 ] |
|
Test case for Doctrine\Tests\ORM\Functional\Ticket |
| Comment by Christian Heinrich [ 07/May/10 ] |
|
It might be worth noting that, after renaming $parent to $parent2, the object is loaded but $item4->children remains empty. If $item3 isn't being fetched beforehands, then everything seems to work fine. |
| Comment by Christian Heinrich [ 12/May/10 ] |
|
After investigating, it came to my mind that the test submitted uses $proxy->publicProperty instead of $proxy->getPublicProperty() Therefore, the proxy is not initialized and thus we get unexpected behaviour. Adding a getter a la "getChildren()" and calling this method only, everything works fine. Therefore, I mark this ticket as invalid. |
| Comment by Nico Kaiser [ 12/May/10 ] |
|
Shouldn't these properties be automagically instantiated? In our project, we did use getChildren() and it did not work either (sorry, can't provide test case now, will do on monday). I think collections are populated automatically everywhere (you can always use $this->children in entities), so this should work here as well. |
| Comment by Christian Heinrich [ 12/May/10 ] |
|
The problem here is, that you're not really using an entity but a proxy object. A proxy object does not initialize its collections, see here: http://www.doctrine-project.org/documentation/manual/2_0/en/best-practices#don%27t-use-public-properties-on-entities As long as you're using normal entities, the PersistentCollections will normally lazy load, thats true. But as soon as you're using proxies - like in this case - you're running into severe problems. I strongly recommend not using public properties. |
| Comment by Nico Kaiser [ 17/May/10 ] |
|
You are right - if I use getChildren and a "protected $children", this example works. |
| Comment by Nico Kaiser [ 17/May/10 ] |
|
Updated DDC531Test.php to use SINGLE_TABLE inheritance. Breaks again, even if I don't use public members for the collection... |
| Comment by Christian Heinrich [ 17/May/10 ] |
|
Hi Nico, thanks for your response. I will take a look at this issue shortly and will hopefully resolve it before beta2. regards |
| Comment by Roman S. Borschel [ 20/May/10 ] |
|
Thanks for your investigation. I tracked down the issue and have a fix pending. Note though, that with such an example as in the provided testcase, the parents can never be lazy. That means all parents will be eagerly loaded. Of course you can work around that by eager-joining them in DQL or by using Query::HINT_FORCE_PARTIAL_LOAD and things like that. The reason why the parents in the example can not be lazy is because a parent can potentially be of any subtype, so you would not know which proxy to put in. In general, a single-valued association that points to another entity that has mapped subclasses can not be lazy. This "problem" does not occur when the targeted entity has no mapped subclasses (this means it either does not participate in a mapped inheritance hierarchy or it is a leaf in the hierarchy). See also: http://www.doctrine-project.org/jira/browse/DDC-357 |
| Comment by Roman S. Borschel [ 23/May/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/616f2eda0af1a15ba205cc5013b5f001c34dfc55 |
[DDC-518] Merging an entity with a one to one association to a MANAGED entity with no id throws 'The given entity has no identity.' Created: 13/Apr/10 Updated: 30/Jul/10 Resolved: 30/Jul/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-BETA3 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Dave Keen | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Calling merge($entity) where $entity has a one to one association to another entity that has been persisted but not yet flushed (when using auto-generated ids) throws 'The given entity has no identity.' It looks like it does this because _doMerge in UnitOfWork assumes for one to one associations only that the associated entity has an id and calls registerManaged, which then calls addToIdentityMap)on it. I think that registeredManaged should only be called if !isset($this->_entityInsertions[spl_object_hash($other)]) Reproduce.php // This is a new element $doctor = new \vo\Doctor(); $d1->name = "New doctor"; // This is a detached element which is in the database $patient = new \vo\Patient(); $p1->name = "Existing patient"; $p1->id = 1; $doctor->patients->add($patient); $patient ->doctor = $doctor; $em->persist($doctor); // This throws InvalidArgumentException: The given entity has no identity. in D:\Projects\ORM\flextrine2\flextrine\web\lib\Doctrine\ORM\UnitOfWork.php on line 1014 $em->merge($patient); Doctor.php class Doctor {
/** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
public $id;
/** @Column(length=100, type="string") */
public $name;
/**
* @OneToMany(targetEntity="Patient", mappedBy="doctor", fetch="EAGER")
*/
public $patients;
public function __construct() {
$this->patients = new ArrayCollection();
}
}
Patient.php class Patient {
var $_explicitType = "vo/Patient";
/** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
public $id;
/** @Column(length=100, type="string") */
public $name;
/**
* @OneToOne(targetEntity="Doctor", inversedBy="patients")
* @JoinColumn(name="doctor_id", referencedColumnName="id")
*/
public $doctor;
}
|
| Comments |
| Comment by Roman S. Borschel [ 08/May/10 ] |
|
I think the order of operations in your example is not correct even though the error is misleading. You are associating a "new doctor" to a "detached patient". That does not seem right, remember that merge() returns a managed copy, thus when merging the patient later, the "new doctor" is still associated with the "detached patient", not with the managed one. The following should work: // Merge detached patient $managedPatient = $em->merge($patient); // Associate new doctor with patient $doctor->patients->add($managedPatient); $managedPatient->doctor = $doctor; // Persist new doctor and flush $em->persist($doctor); $em->flush(); |
| Comment by Dave Keen [ 16/May/10 ] |
|
You are quite right - that does work. However, I am now trying to implement my use case (turning a tree of detached objects into a tree of managed objects) and implementing the correct order you describe above seems to cause another problem. I am not sure if this should be another ticket, but I'll put it here for the moment. Note that the part within the stars that creates the unmanaged doctor and the detached patient simulates exactly what is received by Doctrine in my application so I can't put any merges in here. /********************************************************************/ // This is a new element $doctor = new \vo\Doctor(); $doctor->name = "New doctor"; // This is a detached element which is in the database $patient = new \vo\Patient(); $patient->name = "Existing patient"; $patient->id = 1; $doctor->patients->add($patient); $patient->doctor = $doctor; /********************************************************************/ // Now replace $patient with its managed version $managedPatient = $em->merge($patient); $doctor->patients->set(0, $managedPatient); // Persist the doctor $em->persist($doctor); $em->flush(); This works up to the flush, which throws an error of the form: Notice: Undefined index: 000000007dd346c3000000005d0908d2 in \Doctrine\ORM\UnitOfWork.php on line 1955 In the database this results in a new doctor being created, but doctor_id in the patients table is set to NULL for the patient that is supposed to be linking to it. |
| Comment by Benjamin Eberlei [ 06/Jun/10 ] |
|
I think this can't work, because obviously $doctor->patients still points to the unmanaged $patient, not the managed one. Can you elaborate on why the star part is done by Doctrine? Where is doctrine doing that? what are you doing with the public API? All the detached entities should be merged before doing anything regarding a NEW entity in my opinion. |
| Comment by Benjamin Eberlei [ 06/Jun/10 ] |
|
Moved to beta3 for now |
| Comment by Benjamin Eberlei [ 06/Jun/10 ] |
|
Patch with test-case for this merging scenario |
| Comment by Roman S. Borschel [ 30/Jul/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/69073c4b37ee28f988306db4965f512b70f45181 |
[DDC-500] Single Table Inheritance Selects Created: 07/Apr/10 Updated: 26/Apr/10 Resolved: 26/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Michael Ridgway | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
We have a set of models that use Single Table inheritance and we are trying to select all objects of one type: /** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"Child"="Child", "OtherChild"="OtherChild"}) */ abstract class ParentModel { /** * @Id @Column(name="id", type="integer") * @GeneratedValue(strategy="AUTO") */ protected $id; /** @Column(type="string") */ public $property; function getId() {return $this->id;} } abstract class SubParent extends ParentModel { } /** * @Entity */ class Child extends SubParent { /** @Column(type="string") */ public $anotherProperty; } /** * @Entity */ class OtherChild extends SubParent { /** @Column(type="string") */ public $someOtherProperty; } Now to query for all of the Child objects we do: $children = $em->getRepository('Child')->findall();
foreach($children AS $child) {
echo $child->getId();
}
but we get "Notice: Undefined index: id in ./Doctrine/ORM/UnitOfWork.php on line 1727" on the finAll() call and the objects that aren't of the correct type have their properties nulled out. This is because the query that is being executed doesn't have any conditionals for the type of model it's looking for and the ORM doesn't check to make sure that the object is of the correct type. This could be solved by having conditionals in the SQL query (chaining a bunch of 'or' statements for all of the child objects) or by pulling back all of the objects and then filtering out what isn't of the correct type. Unfortunately neither solution seems ideal. I'll try to make a test case for this then. |
| Comments |
| Comment by Michael Ridgway [ 07/Apr/10 ] |
|
Adding another child class just to be clear. |
| Comment by Roman S. Borschel [ 07/Apr/10 ] |
|
Related to |
| Comment by Michael Ridgway [ 07/Apr/10 ] |
|
Attached a unit test that may or may not work. It looks to be a similar issue for sure. |
| Comment by Michael Ridgway [ 08/Apr/10 ] |
|
Fixed test case. Now gives the 'Undefined index: id' error. |
| Comment by Roman S. Borschel [ 19/Apr/10 ] |
|
Reproduced successfully and working on it. |
| Comment by Roman S. Borschel [ 26/Apr/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/760ea34a0cc3cae4e3caea17e8aab6ceb74ecace |
[DDC-497] find() and findAll() on Repository do not work when SINGLE_TABLE inheritance is used Created: 05/Apr/10 Updated: 26/Apr/10 Resolved: 26/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marcus | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MacOsX 10.6.2 - Zend Server 4.0.6 - PHP 5.3 - MySql 5.1.40 |
||
| Issue Links: |
|
||||||||
| Description |
Class Orm\Models\Car:
@Entity
@Table(name="cars")
@InheritanceType("SINGLE_TABLE")
@DiscriminatorColumn(name="discr", type="string")
@DiscriminatorMap({"car" = "Orm\Models\Car", "bluecar" = "Orm\Models\BlueCar"})
Class Orm\Models\BlueCar extends Orm\Models\Car:
@Entity
Now my Database holds 4 records:
id title discr
1 blue car bluecar
2 only Car car
5 blue car2 bluecar
6 only Car2 car
Now querying objects by Repository leads to some errors.
//quering for all BlueCars
$em->getRepository('Orm\Models\BlueCar')->findAll();
//the result set counts 4 objects
blue car : Orm\Models\BlueCar
: Orm\Models\Car
blue car2 : Orm\Models\BlueCar
: Orm\Models\Car
//The 2 Car Items where the title is missing are to much for this result set, and useless
// there is also a php notice coming up for each Orm\Models\Car object
Notice: Undefined index: id in /library/Doctrine/ORM/UnitOfWork.php on line 1727
I use mysql as Database and so the sql query looks like this.
"SELECT c0.id AS id1, c0.title AS title2, discr FROM cars c0"
It seems that the query is missing the where discriminator = "bluecar" part
querying for Car
$em->getRepository('Orm\Models\Car')->findAll();
blue car: Orm\Models\BlueCar
only Car: Orm\Models\Car
blue car2: Orm\Models\BlueCar
only Car2: Orm\Models\Car
Is working without errors but i think it is a mere chance if you look at the query
"SELECT c0.id AS id1, c0.title AS title2, discr FROM cars c0" it is the same.
I am not shure if it is intended that quering for Cars also returns BlueCars but due to the behavior when using DQL for quering, i guess it is right.
That means, when using DQL:
$q = $em->createQuery('select u from Orm\Models\BlueCar u');
$results = $q->execute();
everything works as expected, so using a custom EntityRepository and override find, findAll and so on is a workaround. So this is a minor bug ?
|
| Comments |
| Comment by Roman S. Borschel [ 05/Apr/10 ] |
|
You mention ALPHA4 as the affected version. Did you test this with trunk? |
| Comment by Roman S. Borschel [ 05/Apr/10 ] |
|
@"I am not shure if it is intended that quering for Cars also returns BlueCars but due to the behavior when using DQL for quering, i guess it is right." Of course. Anything else would be wrong. If you query for cars you get all cars. BlueCars are Cars. |
| Comment by Marcus [ 07/Apr/10 ] |
|
Tested with Revision: 7533. |
| Comment by Roman S. Borschel [ 26/Apr/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/760ea34a0cc3cae4e3caea17e8aab6ceb74ecace |
[DDC-481] Incorrect table aliasing when using quoting on table names Created: 29/Mar/10 Updated: 14/Jun/10 Resolved: 08/May/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers, ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Menno Luiten | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine trunk (r7479) |
||
| Attachments: |
|
| Description |
|
I need to quote several table names (because of reserved words within MySQL) like so: /** * @Entity * @Table(name="`Column`") */ class Column extends OptionAbstract Another entity Question is related one-to-many to these entities, however, when trying to fetch the relation I get SQL errors because it seems to use the backtick as the table alias, which is illegal. An example of the query it's generating: SELECT `0.id AS id1, `0.name AS name2, `0.sequence AS sequence3, `0.question_id AS question_id4 FROM `Column` `0 WHERE question_id = ? |
| Comments |
| Comment by Menno Luiten [ 29/Mar/10 ] |
|
Here's a patch that works for me; looping through the table name until there is a character in the range a-z (case insensitive) to use as an alias. Might need some more error-reporting and endless loop protection etc. |
| Comment by Roman S. Borschel [ 29/Mar/10 ] |
|
Thanks but the problem is elsewhere. The table name should not have the quote characters. The quote characters should be stripped during metadata parsing and instead a flag quoted => true set for the table in ClassMetadata::$table. Its not hard to fix, we will look into it soon. |
[DDC-448] Cannot select rows from chield table by JoinColumn in @InheritanceType("JOINED") parent table Created: 20/Mar/10 Updated: 13/Apr/10 Resolved: 12/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, ORM |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Uvarov Michael | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This bug is connected with http://www.doctrine-project.org/jira/browse/DDC-416 /** * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="smallint") * @DiscriminatorMap({ * "0" = "mainTable", * "1" = "SubTable" * }) */ class mainTable { /** * @Id * @Column(name="id", type="integer") * @GeneratedValue(strategy="AUTO") */ private $id; /** * @ManyToOne(targetEntity="connectedClass", cascade={"all"}, fetch="EAGER") * @JoinColumn(name="connectedClassId", referencedColumnName="id", onDelete="CASCADE", onUpdate="CASCADE", nullable=true) */ private $connectedClassId; } /** * @Entity * @Table(name="connectedClass") * @HasLifecycleCallbacks */ class connectedClass { /** * @Id * @Column(name="id", type="integer") * @GeneratedValue(strategy="AUTO") */ protected $id; // connected with mainTable } /** * @Entity * @Table(name="SubTable") */ class SubTable extends mainTable { } $qb->select(array('b')) ->from('SubTable', 'b') ->where( $qb->expr()->eq('b.connectedClassId', '?1') // select by JoinColumn field does not work // select by normal column work (after http://www.doctrine-project.org/jira/browse/DDC-416 ) ) ->setParameter(1, $value); // $value - const or connectedClass object Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'i1_.connectedClassId' in 'where clause'' in /var/www/shelly/library/Doctrine/DBAL/Connection.php:573 Stack trace: #0 /var/www/shelly/library/Doctrine/DBAL/Connection.php(573): PDOStatement->execute(Array) #1 /var/www/shelly/library/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(42): Doctrine\DBAL\Connection->execute('SELECT p0_.id A...', Array) #2 /var/www/shelly/library/Doctrine/ORM/Query.php(231): Doctrine\ORM\Query\Exec\SingleSelectExecutor->execute(Object(Doctrine\DBAL\Connection), Array) #3 /var/www/shelly/library/Doctrine/ORM/AbstractQuery.php(514): Doctrine\ORM\Query->_doExecute(Array) #4 /var/www/shelly/library/Doctrine/ORM/AbstractQuery.php(391): Doctrine\ORM\AbstractQuery->execute(Array, NULL) So, we cannot select rows by JoinColumn from Inheritance tables, because doctrine selects SubTable.connectedClassId field, not mainTable.connectedClassId This bug was fix in http://www.doctrine-project.org/jira/browse/DDC-416 patch, but it was not commited. I may write unit test for this problem |
| Comments |
| Comment by Guilherme Blanco [ 12/Apr/10 ] |
|
In http://github.com/doctrine/doctrine2/commit/56a8f5cd5353908b815607a6e089201c95e01e6c this issue was fixed! Thanks for the report! |
| Comment by Roman S. Borschel [ 13/Apr/10 ] |
|
The testcase is irritating though, because connectedClassId is an object, not an id. |
[DDC-419] Problem when I make a INNER JOIN between 2 classes Created: 12/Mar/10 Updated: 08/Aug/10 Resolved: 08/Aug/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-BETA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Henrique Girardi dos Santos | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 9.10 |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
I hae some problems when I make a inner join between 2 classes, one of these classes makes join to others 2 classes in the same time and when I try to make a inner to this class, it's not coming like a object, but object Id... I don't know why its happening.. I make a test case..there're all the classes and yml that show my problem..it's on ItemPregaoTest.php.. just need to run phpunit in this file.. |
| Comments |
| Comment by Benjamin Eberlei [ 14/Mar/10 ] |
|
This is what returns for me: object(stdClass)[82] public '__CLASS__' => string 'ItemPregao' (length=10) public 'id' => int 1 public 'item' => string '1' (length=1) The expected result I guess. What happens for you? |
| Comment by Henrique Girardi dos Santos [ 14/Mar/10 ] |
|
Ok...this is what happen for me... object(stdClass)[82] public '__CLASS__' => string 'ItemPregao' (length=10) public 'id' => int 1 public 'item' => string 'Item' (length=4) because 'public item' makes refereces to Item class, so I think it should give me a Item class, not its Id... |
| Comment by Henrique Girardi dos Santos [ 16/Mar/10 ] |
|
When I try to make a inner join between Item and ItemPregao, happens what I've said before, but if I make a inner join between Item and its refereces tables, it's working fine $qb = $this->em->createQueryBuilder(); $qb->select('i, cc, ca, cl') ->from('Item', 'i') ->innerJoin('i.classificacaoCatalogo', 'cc') ->innerJoin('cc.catalogo', 'ca') ->innerJoin('cc.classificacao', 'cl') ; object(stdClass)[141] public '__CLASS__' => string 'Item' (length=4) public 'id' => int 1 public 'descricao' => string 'ITEM 1' (length=6) public 'classificacaoCatalogo' => object(stdClass)[99] public '__CLASS__' => string 'ClassificacaoCatalogo' (length=21) public 'id' => int 1 public 'classificacao' => string 'Classificacao' (length=13) public 'catalogo' => string 'Catalogo' (length=8) It brings a class on 'classificacaoCatalogo' and inside classificacaoCatalogo you can see that 'classificacao' and 'catalogo' are objects too..so it worked! But If I make this: $qb = $this->em->createQueryBuilder();
$qb->select('ip, i')
->from('ItemPregao', 'ip')
->innerJoin('ip.item', 'i');
do not work like before.. object(stdClass)[152] public '__CLASS__' => string 'ItemPregao' (length=10) public 'id' => int 1 public 'item' => int 1 'item' should be a object, not a integer.. |
| Comment by Benjamin Eberlei [ 16/Mar/10 ] |
|
Ah now I see it. Yes, this seems to be a problem. |
| Comment by Benjamin Eberlei [ 18/Mar/10 ] |
|
I have taken some time now trying to re-produce it, there is definately a bug i have identified, however i havent found the reason yet. |
| Comment by Henrique Girardi dos Santos [ 18/Mar/10 ] |
|
ok man! |
| Comment by Benjamin Eberlei [ 20/Mar/10 ] |
|
I found the issue. A quick fix is to rename the join column to "item_id" instead of "item". This is causing the bug, we will look how to fix it. @Roman: This is particularly nasty, in UnitOfWork::createEntity the join column is set to the field name in $data, which makes the following code write the primitive FK value to the entity: if ($this->_useCExtension) { doctrine_populate_data($entity, $data); } else { foreach ($data as $field => $value) { if (isset($class->reflFields[$field])) { $class->reflFields[$field]->setValue($entity, $value); } } } This then leads in the ObjectHydrator to: // PATH B: Single-valued association $reflFieldValue = $reflField->getValue($parentObject); if ( ! $reflFieldValue || isset($this->_hints[Query::HINT_REFRESH])) { not evaluating to null, but to the primitive value. the If condition does not match here and the relation is never set. A simple solution would be to replace !$reflFieldValue with !is_object(). |
| Comment by Benjamin Eberlei [ 20/Mar/10 ] |
|
Attached a reproduce test-case. |
| Comment by Roman S. Borschel [ 20/Mar/10 ] |
|
I see. As their is an easy workaround, this is not a blocker, however. |
| Comment by Roman S. Borschel [ 15/Apr/10 ] |
|
|
| Comment by Roman S. Borschel [ 15/Apr/10 ] |
|
Scheduled for beta2 |
| Comment by Roman S. Borschel [ 08/Aug/10 ] |
|
Should be fixed now in master. |
[DDC-388] Private properties in @MappedSupperclass don't work Created: 03/Mar/10 Updated: 14/Apr/10 Resolved: 14/Apr/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Mapping Drivers |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Jaka Jancar | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Environment: |
PHP 5.3.1 |
||
| Issue Links: |
|
||||||||
| Description |
|
All of my entites extend an abstract class Model to inherit the 'id' property and some other functionality. It has the @MappedSuperclass annotation. If the id property is declared private to the Model class, I'll get the following exception when using entites extending it: [03-Mar-2010 11:36:29] exception 'ReflectionException' with message 'Property id does not exist' in library/Doctrine/ORM/Mapping/ClassMetadata.php:370
Stack trace:
#0 library/Doctrine/ORM/Mapping/ClassMetadata.php(370): ReflectionClass->getProperty('id')
#1 [internal function]: Doctrine\ORM\Mapping\ClassMetadata->__wakeup()
...
I haven't looked at Doctrine code, but perhaps you should be looking for the property on the class which actually has the @Column annotation? |
| Comments |
| Comment by Roman S. Borschel [ 03/Mar/10 ] |
|
Yes, I think the 'inherited' key is simply not set for fields that are inherited from mapped superclasses. This needs to be fixed. |
| Comment by Roman S. Borschel [ 14/Apr/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/d4232d906e433b1fe4dd8aa85aa7a4aca3a2cf4c . |
[DDC-335] Refactor DQL EBNF to use JOIN FETCH as syntax for fetch joins only Created: 14/Feb/10 Updated: 19/Feb/10 Resolved: 19/Feb/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Improvement | Priority: | Critical |
| Reporter: | Benjamin Eberlei | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
There are several problems with the current approach on fetch joins: 1. There is no way to determine in the parser already if a join is fetch or not, this makes it much harder to implement things like @OrderBy or @OrderColumn Solution, change the EBNF too: Join ::= ["LEFT" ["OUTER"] | "INNER"] "JOIN" [FETCH] JoinAssociationPathExpression ["AS"] AliasIdentificationVariable [("ON" | "WITH") ConditionalExpression] Question would be how to specify partial object selects. Romans idea was something like: select u.{name, other, field, stuff}
However my take is this would again put information into the select clause that might be interesting elsewhere, so SELECT u FROM User u JOIN FETCH u.group PARTIAL id, name That way we could add both $isFetchJoin and $isPartial flags to the AST/Join Node plus an additional $partialFields array. |
| Comments |
| Comment by Benjamin Eberlei [ 16/Feb/10 ] |
|
Ah just to remember, the idea on the partial fetch syntax was something like: select u FROM User u.{name, other, field, stuff} JOIN FETCH u.group g.{id, name, baz}
|
| Comment by Benjamin Eberlei [ 16/Feb/10 ] |
|
I think this will also make the HINT_PARTIAL_LOAD constant obsolet, since the DQL is already implicitly requesting a partial load. |
| Comment by Roman S. Borschel [ 16/Feb/10 ] |
|
Regarding HINT_FORCE_PARTIAL_LOAD: Not necessarily, but it might need to be renamed since its still used to decide whether to stub associations with empty collections/proxies. Anyways, I've played around a bit with different implementations in the last days and I changed my mind regarding changing the fetch join syntax. It has many complications, like more difficult sql construction in the walker, among other things, and of course the fact that it would be a huge bc break. However, some things will change. "select u.name" will select a scalar value, as you expect. The new syntax for partial object selection will currently be: select partial u.{id,name}, partial a.{id,city} from User u join u.address a
There will be a new AST node PartialObjectExpression that represents such a construct. Thats the current state of my progress. Regarding the isFetchJoin/isPartial decisions, we need to find another way and I'm confident there are some other ways. So far... |
| Comment by Benjamin Eberlei [ 16/Feb/10 ] |
|
If we change u.name to retrieving a scalar value always its easy to get all the fetch joins identification variables inside the SELECT already: If (identificiationVariable) => fetchJoin Then when the join is found, you can mark the Join as Fetch already. |
| Comment by Roman S. Borschel [ 19/Feb/10 ] |
|
Implemented. |
[DDC-317] Using a function only in hydration returns only one result Created: 11/Feb/10 Updated: 19/Feb/10 Resolved: 19/Feb/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-BETA1 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Benjamin Eberlei | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Output of $arg: array(1) {
[-1]=>
array(1) {
["namedep"]=>
string(25) "Jonathan W.Administration"
}
}
public function testConcatFunction() { $this->generateFixture(); $arg = $this->_em->createQuery('SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getArrayResult(); $this->assertEquals(4, count($arg)); // fails with 1 } protected function generateFixture() { $manager1 = new CompanyManager(); $manager1->setName('Roman B.'); $manager1->setTitle(''); $manager1->setDepartment('IT'); $manager1->setSalary(100000); $manager2 = new CompanyManager(); $manager2->setName('Benjamin E.'); $manager2->setTitle(''); $manager2->setDepartment('HR'); $manager2->setSalary(200000); $manager3 = new CompanyManager(); $manager3->setName('Guilherme B.'); $manager3->setTitle(''); $manager3->setDepartment('Complaint Department'); $manager3->setSalary(400000); $manager4 = new CompanyManager(); $manager4->setName('Jonathan W.'); $manager4->setTitle(''); $manager4->setDepartment('Administration'); $manager4->setSalary(800000); $this->_em->persist($manager1); $this->_em->persist($manager2); $this->_em->persist($manager3); $this->_em->persist($manager4); $this->_em->flush(); $this->_em->clear(); } |
| Comments |
| Comment by Benjamin Eberlei [ 11/Feb/10 ] |
|
Additional bug, changing the DQL to: SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m WHERE m.id = 4 returns an empty result. |
| Comment by Benjamin Eberlei [ 11/Feb/10 ] |
|
Thie following DQL gives a partial error bug: SELECT m, m.salary+2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m Error: Doctrine\Tests\ORM\Functional\QueryDqlFunctionTest::testOperatorAdd() Exception: [Doctrine\Common\DoctrineException] Loading partial objects is dangerous. Fetch full objects or consider using a different fetch mode. If you really want partial objects, set the doctrine.forcePartialLoad query hint to TRUE. |
| Comment by Benjamin Eberlei [ 11/Feb/10 ] |
|
The same goes for - * and / |
| Comment by Benjamin Eberlei [ 13/Feb/10 ] |
|
Generated SQL of the CONCAT Example: SELECT CONCAT(c0_.name, c1_.department) AS sclr0 FROM company_managers c2_ INNER JOIN company_employees c1_ ON c2_.id = c1_.id INNER JOIN company_persons c0_ ON c2_.id = c0_.id |
| Comment by Roman S. Borschel [ 19/Feb/10 ] |
|
Should be fixed now. |
[DDC-610] Numeric strings are not quoted Created: 25/May/10 Updated: 25/May/10 Resolved: 25/May/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-BETA1 |
| Fix Version/s: | 2.0-BETA2 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | David Abdemoulaie | Assignee: | David Abdemoulaie |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I've been working on a MaterializedPath implementation and hit a roadblock. This condition: // $pathInterval = array('00010001', '0001ZZZZ');
$andX->add($expr->between('e.' . $this->getPathFieldName(), $expr->literal($pathInterval[0]), $expr->literal($pathInterval[1])));
results in this SQL: AND (l0_.path BETWEEN 00010000 AND '0001ZZZZ') This is clearly not correct. Numeric strings should still be quoted if the field is of type string. |
| Comments |
| Comment by David Abdemoulaie [ 25/May/10 ] |
|
Fixed in http://github.com/doctrine/doctrine2/commit/b6a5402bcb014e78eb6c0b841609e6f0bba71ef6 |
[DDC-168] serialization/unserialization of ClassMetadata lose reflFields order causing insertSql statement to fail Created: 20/Nov/09 Updated: 17/Dec/09 Resolved: 17/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA4 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Eric Durand-Tremblay | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This problem will be difficult to reproduce for you, but I isolated the exact cause of it. To reproduce
I narrowed it down to a serialization issue. When you serialize an MetadataInfo, you don't serialize reflFields. The problem is that somehow, the reflection class can return the fields not in the same order that they were at the initial creation of the MetadataInfo. Because the insertSql value is not re-generated, it can be out of sync with the new fields order. The solution : |
| Comments |
| Comment by Roman S. Borschel [ 21/Nov/09 ] |
|
Are you using composite keys anywhere? The fact that reflFields is not serialized is not really an optimization but rather due to the fact that they simply can can not be serialized/unserialized properly. We surely need some more concrete test case in order to reproduce this. |
| Comment by Eric Durand-Tremblay [ 23/Nov/09 ] |
|
I do not uses composite key anyware. The field who change place is a foreign key. EntityRevision extends Entity (the field parent_entity_id changes place during serialization) What do you need to reproduce the case ? Just entitiy classes? a completely fuctionnal project? some kind of unit test ? |
| Comment by Roman S. Borschel [ 05/Dec/09 ] |
|
Hm. the order shouldnt even matter because insertSql only contains placeholders. Can you show the SQL INSERT that is failing? With parameters, if possible, and error message. |
| Comment by Eric Durand-Tremblay [ 06/Dec/09 ] |
|
For what I can remember, parameters are not bound in the right order which is causing an error like "field x could not be null" INSERT INTO table (a, b) VALUES (?, ?) bind : $b, $a I will post the real query on monday morning when I get back to work. |
| Comment by Eric Durand-Tremblay [ 07/Dec/09 ] |
|
Here is the real world example. I put the statement, the parameters, the error, and all the related entities. INSERT INTO fna_client_revision (fna_parent_record_id, record_id, display_name, last_name, maiden_name, first_name, civility, gender, birthdate, employer, employment, employment_from, civil_status, civil_status_from, insurability, fna_client_fna_id, fna_spouse_fna_id, rev_no, created_at, modified_at, created_by, modified_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Array
(
[1] => 1
[2] => George Simard2
[3] => Simard2
[4] =>
[5] => George
[6] =>
[7] => MALE
[8] => 1962-09-14
[9] => Plomberie ABC Inc.
[10] => Plombier
[11] =>
[12] => MARRIED
[13] =>
[14] => INSURABLE
[15] => 5
[16] => 2009-12-07 08:54:46
[17] => 2009-12-07 08:54:46
[18] => Eric Durand-Tremblay
[19] => Eric Durand-Tremblay
[20] => 1
[21] =>
[22] =>
)
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'employment' cannot be null
namespace ORM\BaseEntity;
/**
* @MappedSuperclass
*/
class Entity
{
private static $boolean_values = array("YES", 'NO');
/**
* @Column(name="id", type="integer")
* @Id
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Column(name="created_at", type="datetime")
*/
protected $created_at;
/**
* @Column(name="modified_at", type="datetime")
*/
protected $modified_at;
/**
* @Column(name="created_by", type="string")
*/
protected $created_by="";
/**
* @Column(name="modified_by", type="string")
*/
protected $modified_by="";
}
/**
* @MappedSuperclass
* @HasLifecycleCallbacks
*/
class Revisionable extends ORM\BaseEntity\Entity
{
/**
* @Column(name="rev_no", type="integer")
*/
protected $revision=1;
}
namespace ORM\BaseEntity;
/**
* @MappedSuperclass
* @HasLifecycleCallbacks
*/
class Client extends Revisionable
{
/**
* @Column(name="display_name", type="string")
*/
protected $display_name;
/**
* @Column(name="last_name", type="string")
*/
protected $last_name="";
/**
* @Column(name="maiden_name", type="string")
*/
protected $maiden_name="";
/**
* @Column(name="first_name", type="string")
*/
protected $first_name="";
/**
* @Column(name="civility", type="string")
*/
protected $civility="";
/**
* @Column(name="gender", type="string", length="25")
*/
protected $gender="";
/**
* @Column(name="birthdate", type="date", nullable="true")
*/
protected $birthdate;
/**
* @Column(name="employer", type="string")
*/
protected $employer="";
/**
* @Column(name="employment", type="string")
*/
protected $employment="";
/**
* @Column(name="employment_from", type="date", nullable="true")
*/
protected $employment_from;
/**
* @Column(name="civil_status", type="string", length="25")
*/
protected $civil_status="";
/**
* @Column(name="civil_status_from", type="date", nullable="true")
*/
protected $civil_status_from;
/**
* @Column(name="insurability", type="string", length="25")
*/
protected $insurability="";
/**
* @OneToOne(targetEntity="ORM\Entity\FNA")
* @JoinColumns({
* @JoinColumn(name="fna_client_fna_id", referencedColumnName="id")
* })
*/
protected $client_fna;
/**
* @OneToOne(targetEntity="ORM\Entity\FNA")
* @JoinColumns({
* @JoinColumn(name="fna_spouse_fna_id", referencedColumnName="id")
* })
*/
protected $spouse_fna;
}
namespace ORM\RevisionEntity;
/**
* @Entity
* @Table(name="fna_client_revision", indexes={@index(name="idx_record_id", columns={"record_id"})})
* @HasLifecycleCallbacks
*/
class Client extends ORM\BaseEntity\Client{
/**
* @ManyToOne(targetEntity="Kronos\FNA\ORM\Entity\Client")
* @JoinColumns({
* @JoinColumn(name="fna_parent_record_id", referencedColumnName="id", onDelete="SET NULL")
* })
*/
protected $parent_record; /// HERE IS THE FIELD WHO CHANGE PLACE AFTER SERIALIZATION !!!!!!!!!!!!!!!!!!!!!!
/**
*
* @Column(name="record_id", type="int")
*/
protected $record_id;
}
|
| Comment by Eric Durand-Tremblay [ 07/Dec/09 ] |
[1] => 1 (fna_parent_record_id)
(expected record_id)
[2] => George Simard2 (display_name)
[3] => Simard2 (last_name)
[4] => (maiden_name)
[5] => George (first_name)
[6] => (civility)
[7] => MALE (gender)
[8] => 1962-09-14 (birthdate)
[9] => Plomberie ABC Inc. (employer)
[10] => Plombier (employment)
[11] => (employment_from)
[12] => MARRIED (civil_status)
[13] => (civil_status_from)
[14] => INSURABLE (insurability)
[15] => 5 (rev_no)
[16] => 2009-12-07 08:54:46 (created_at)
[17] => 2009-12-07 08:54:46 (modified_at)
[18] => Eric Durand-Tremblay (created_by)
[19] => Eric Durand-Tremblay (modified_by)
[20] => 1 (record_id) !! Should be in position 2
[21] => (fna_client_fna_id)
[22] => (fna_spouse_fna_id)
|
| Comment by Benjamin Eberlei [ 07/Dec/09 ] |
|
I could reproduce the issue and generated a failing test for this. We already discussed how this might be fixed. |
| Comment by Eric Durand-Tremblay [ 07/Dec/09 ] |
|
This is a very good news ! |
| Comment by Roman S. Borschel [ 17/Dec/09 ] |
|
Should be fixed now. |
| Comment by Eric Durand-Tremblay [ 17/Dec/09 ] |
|
Resolution confirmed. Thank your for your great work ! |
[DDC-164] find() not polymoprhic with single table inheritance Created: 20/Nov/09 Updated: 21/Nov/09 Resolved: 21/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
[DDC-152] Polymorphic queries and fields of subclasses Created: 16/Nov/09 Updated: 19/Dec/09 Resolved: 19/Dec/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL, ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Currently fields of subclasses are added to the ResultSetMapping under the alias of the queried (parent) class. Later during hydration if the queried (parent) class does not own a field AbstractHydrator#_lookupDeclaringClass looks up the first subclass that defines a field with that name. However, multiple subclasses can define a field with the same name, so this is error-prone. Fields of subclasses in a polymorphic query should probably be added to the ResultSetMapping with their own alias. The lookup during hydration should be removed and the information which field belongs to which class encoded in the ResultSetMapping. |
[DDC-145] Cascaded delete on a lazyloaded persistent collection Created: 13/Nov/09 Updated: 13/Nov/09 Resolved: 13/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Avi Block | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
It seems that if you call PersistentCollection#unwrap on a lazy loaded collection, you get nothing back (unless you initialize the collection first). Because of this, UnitOfWork#_cascadeRemove is "unwrapping" the collection before transversing it, and nothing gets deleted on the cascade. |
| Comments |
| Comment by Roman S. Borschel [ 13/Nov/09 ] |
|
Right, I think I made that change for all _cascade* methods but actually I think for _cascadeRemove initialization is actually intended. For the others it doesnt make sense. |
| Comment by Roman S. Borschel [ 13/Nov/09 ] |
|
Will need to write a functional test for this before I fix it by reverting the change for _cascadeRemove. |
[DDC-141] DQL with WHERE queries on Single Table Inheritance Entities fail Created: 13/Nov/09 Updated: 13/Nov/09 Resolved: 13/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Nico Kaiser | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The ORM query builder seems to be broken for Single Table Inheritance with discriminator. When using inheritance like here: Queries with WHERE fail: SELECT p FROM MyProject\Model\Person p WHERE p.id = 1 This translates to this SQL: SELECT p0_.id AS id0, p0_.discr AS discr1 FROM person p0_ WHERE p0_.id = 1 p0_.discr IN ('', 'person', 'employee') (AND is missing after p0_.id = 1) |
| Comments |
| Comment by Roman S. Borschel [ 13/Nov/09 ] |
|
Thanks for reporting this. I'm just wondering where the empty string in the IN clause comes from? I dont seem to be able to reproduce that bit. |
| Comment by Nico Kaiser [ 13/Nov/09 ] |
|
Argh, ignore the empty string, it is SELECT p0_.id AS id0, p0_.discr AS discr1 FROM person p0_ WHERE p0_.id = 1 p0_.discr IN ('person', 'employee') My initial example was a superclass that did not appear in the DiscriminatorMap... |
| Comment by Roman S. Borschel [ 13/Nov/09 ] |
|
OK. Should be fixed now. Was a very trivial mistake. Now its covered in the tests. |
[DDC-137] Only last relation id updated with multiple one-to-one self-referencing relations Created: 12/Nov/09 Updated: 15/Nov/09 Resolved: 15/Nov/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0-ALPHA3 |
| Fix Version/s: | 2.0-ALPHA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Reinier Kip | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Take this simplified situation: /** @Entity */
class Entity {
/** @Id @GeneratedValue(strategy="AUTO") @Column(type="integer") */
public $id;
/**
* @OneToOne(targetEntity="Entity", cascade={"persist"})
* @JoinColumn(name="other1", referencedColumnName="id")
*/
public $other1;
/**
* @OneToOne(targetEntity="Entity", cascade={"persist"})
* @JoinColumn(name="other2", referencedColumnName="id")
*/
public $other2;
}
$entity1 = new Entity();
$em->persist($entity1);
$entity1->other1 = $entity2 = new Entity();
$entity1->other2 = $entity3 = new Entity();
$em->flush();
The entities' ids are now: Entity 1: 1, Entity 2: 2, Entity 3: 3 However, the other1's relation id is not updated: id other1 other2
1 NULL 3: // other1's id is missing
2 NULL NULL
3 NULL NULL
The SQL clarifies: INSERT INTO Entity (other1, other2) VALUES (?, ?)
array(2) {
[1]=>
NULL
[2]=>
NULL
}
INSERT INTO Entity (other1, other2) VALUES (?, ?)
array(2) {
[1]=>
NULL
[2]=>
NULL
}
INSERT INTO Entity (other1, other2) VALUES (?, ?)
array(2) {
[1]=>
NULL
[2]=>
NULL
}
UPDATE Entity SET other2 = ? WHERE id = ?
array(2) {
[0]=>
int(3)
[1]=>
int(1)
}
Adding 'other3' proved that only the last relation id is updated, as such: id other1 other2 other3
1 NULL NULL 4 // other1 and other2 missing
2 NULL NULL NULL
3 NULL NULL NULL
4 NULL NULL NULL
This is not the case with relations that reference to entities outside the class hierarchy (so the same problem occurs with relations inside the class hierarchy). |
| Comments |
| Comment by Roman S. Borschel [ 15/Nov/09 ] |
|
Thanks, should be fixed now. |
[DDC-2] Proxies in UoW::_computeChangeSets Created: 09/Sep/09 Updated: 06/Oct/09 Resolved: 06/Oct/09 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0 |
| Fix Version/s: | 2.0 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Roman S. Borschel | Assignee: | Roman S. Borschel |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
|
When having a proxy object, say "PhonenumberProxy? extends Phonenumber", and its not yet loaded from the database I think an error occures in the UnitOfWork::_computeChangeSets function since it goes and retrieves that lazy load object value using an instance of "ReflectionProperty?". However with it being lazily loaded the value must be null. |
[DDC-875] Merge can sometimes add the same entity twice into a collection Created: 11/Nov/10 Updated: 11/Mar/12 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: |
|
| 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 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 |
| 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. |
[DDC-792] CLI run-dql --max-result switch calls undefined method Created: 07/Sep/10 Updated: 15/Sep/10 Resolved: 15/Sep/10 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | Tools |
| Affects Version/s: | 2.0-BETA4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Marc Hodgins | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
doctrine orm:run-dql "SELECT a FROM Entity\Foo a" --max-result=1
Result: PHP Fatal error: Call to undefined method Doctrine\ORM\Query::setMaxResult() in /var/www/mysite.com/library/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php on line 117 Fatal error: Call to undefined method Doctrine\ORM\Query::setMaxResult() in /var/www/mysite.com/library/Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php on line 117 Solution: Update line 117 of Doctrine/ORM/Tools/Console/Command/RunDqlCommand.php to call setMaxResults rather than setMaxResult |
| Comments |
| Comment by Guilherme Blanco [ 15/Sep/10 ] |
|
On http://github.com/doctrine/doctrine2/commit/2e3c1506fbeec0f3598a71c8a9624b72c59e3674 this issue was fixed. Thanks for the report! =) |
[DDC-775] Ability to use IFNULL() function in ORDER BY clause Created: 29/Aug/10 Updated: 25/Mar/12 Resolved: 25/Mar/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Glen Ainscow | Assignee: | Fabio B. Silva |
| Resolution: | Won't Fix | Votes: | 2 |
| Labels: | None | ||
| Description |
$qb = $em->createQueryBuilder(); /* @var $qb Doctrine\ORM\QueryBuilder */
$roles = $qb->from('App_Model_Role', 'r')
->select('r')
->orderBy('IFNULL(r.rootId, r.id), r.lft')
->getQuery()
->getResult();
[Syntax Error] line 0, col 46: Error: Expected end of string, got '(' |
| Comments |
| Comment by Nikita Chirkov [ 20/Feb/12 ] |
|
I have the same error while using FIELD mysql function. I added beberlei/DoctrineExtensions to my Symfony2 project to enable the FIELD function, but I'm able to use it in SELECT clause only. The problem is that in that case Doctrine returns bad result for me. Here is the example: $queryBuilder
->addSelect('FIELD(u.id, 1, 2) as relevanceField')
->orderBy('relevanceField')
;
The result of foreach($queryBuilder->getQuery()->getResult() as $r) { ... }
is: Array(Object, relevanceField) Array(Object, relevanceField) ... Without that addSelect() function call I have correct result: Object Object ... So I think orderByItem() function in Parser.php class should be extended so that MySQL function could be used there. |
| Comment by Fabio B. Silva [ 20/Feb/12 ] |
|
Hi Nikita, I have a pull request under discussion about this ticket : please follow, and fell free to comment. |
| Comment by Fabio B. Silva [ 25/Mar/12 ] |
|
i'm +1 for this feature. More details : https://github.com/doctrine/doctrine2/pull/288 |
[DDC-1284] Inheritance fails in JOIN query Created: 21/Jul/11 Updated: 14/Aug/11 Resolved: 14/Aug/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.2 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Carlos Ayala | Assignee: | Guilherme Blanco |
| Resolution: | Can't Fix | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu 10.10 |
||
| Description |
|
Hi! /** * @Entity * @Table(name="entity") * @InheritanceType("JOINED") * @DiscriminatorColumn(name="entityTypeId", type="smallint") * @DiscriminatorMap({0 = "Bank", 1 = "Dealer", 2 = "Debtor", 3 = "Repo", 4 = "Appraiser", 5 = "Transport"}) */ class Entities { /** * @Id @GeneratedValue * @Column(type="integer") * @var integer */ protected $id; /** * @Column(type="string", length=40) * @var text */ protected $name; ............................................................ ............................................................ } ------------------------------------------------------------------------------------------------------------------------------------ /** * @Entity(repositoryClass="Model\Entity\Repository\DebtorRepository") * @Table(name="debtor") */ class Debtor extends Entities{ } ------------------------------------------------------------------------------------------------------------------------------------ /** * @Entity(repositoryClass="Model\Entity\Repository\PlacementRepository") * @Table(name="placement") */ class Placement { /** * @Id * @Column(type="smallint") * @var integer */ protected $id; /** * @ManyToOne(targetEntity="Debtor", inversedBy="placements") * @JoinColumn(name="debtorId", referencedColumnName="id") */ protected $debtor; ........................................ ....................................... } The DQL query:
fails and show the message
I hope somebody know how fix this, I can't fixing this. |
| Comments |
| Comment by Benjamin Eberlei [ 26/Jul/11 ] |
|
Can you call $query->getSQL() and show me the generated SQL statement? or grab it from a log file |
| Comment by Guilherme Blanco [ 14/Aug/11 ] |
|
Hi, This issue is impossible to be fixed by Doctrine side. That's your situation. Since in your individual situation you're doing INNER JOINs, you are pretty much able to fix this by doing a WHERE clause. From Doctrine perspective, this issue is not fixable. Cheers, |
[DDC-1234] With class table inheritance, SqlWalker always joins subclass tables even when they are not used Created: 27/Jun/11 Updated: 16/Oct/11 Resolved: 16/Oct/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.5 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Patrick Schwisow | Assignee: | Guilherme Blanco |
| Resolution: | Can't Fix | Votes: | 1 |
| Labels: | None | ||
| Description |
|
When using class table inheritance, it is not possible to avoid joining subclass tables even if they are not needed. For example, when selecting only scalar fields of the parent class and using array hydration. Classes: /** * @Entity * @InheritanceType("JOINED") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"employee" = "Employee", "customer" = "Customer"}) */ class Person { ... /** @Column(name="name", type="string") */ protected $name; ... } /** @Entity */ class Employee extends Person { ... } Test code: $entityManager->createQueryBuilder()->select('p.name')->from('Person', 'p')->getQuery()->getArrayResult();
The generated SQL includes 'employee' table even though it is not used. |
| Comments |
| Comment by Benjamin Eberlei [ 28/Jun/11 ] |
|
A change that detects this would be considered an improvement, the functionality works, its just not very efficient in this case. I doubt there is a simple and good way to implement this though, i assign this to Guilherme for evaluation. |
| Comment by Guilherme Blanco [ 16/Oct/11 ] |
|
That would require almost a complete rewrite of DQL parser to be able to be done. |
[DDC-1184] ORM\Id\AssignedGenerator try to current() on non-array Created: 30/May/11 Updated: 11/Jun/11 Resolved: 11/Jun/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.1 |
| Fix Version/s: | 2.1 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Slam | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Description |
// Doctrine\ORM\AssignedGenerator::generate at line 54
$identifier[$idField] = current($em->getUnitOfWork()->getEntityIdentifier($value));
$value may also be new, so getEntityIdentifier returns NULL and current(NULL) generates an E_WARNING. |
| Comments |
| Comment by Benjamin Eberlei [ 05/Jun/11 ] |
|
Optimized error handling |
| Comment by Slam [ 08/Jun/11 ] |
|
Error optimizing is welcome but this does not resolve the issue. Again, if $value is new object, for example a new Entity\User with an empty protected $id: if (is_object($value)) { if (!$em->getUnitOfWork()->isInIdentityMap($value)) { throw ORMException::entityMissingForeignAssignedId($entity, $value); } // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced. $identifier[$idField] = current($em->getUnitOfWork()->getEntityIdentifier($value)); } else { $identifier[$idField] = $value; } will ALWAYS throw an exception in the case the Entity is new. In my projects, i resolved with if (is_object($value)) { if (!$em->getUnitOfWork()->isInIdentityMap($value)) { $identifier[$idField] = null; } else { // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced. $identifier[$idField] = current($em->getUnitOfWork()->getEntityIdentifier($value)); } } else { $identifier[$idField] = $value; } I have not unit-tested the solution (i'm sorry) and I think a more accurate investigation is needed. |
| Comment by Benjamin Eberlei [ 11/Jun/11 ] |
|
Please read: This is a necessary requirement, that means if you want to create two entities with a composite pk key of the one depending on the other you have to use two flush operations when using MySQL Auto Increment Keys. This will work with PostgreSQL or Oracle Sequences, but not with Auto increment keys. |
| Comment by Slam [ 11/Jun/11 ] |
|
Ok, roger. Just one note: you must know that both two entities are STATE_NEW, because if you try to getEntityState($dependentEntity), UnitOfWork.php:2155 will throw a E_RECOVERABLE_ERROR because the $independentEntity could not be converted to a string (because it has no id). |
[DDC-1175] Call chaining for entity manager Created: 27/May/11 Updated: 30/May/11 Resolved: 30/May/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.x |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | David Vega | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
It would be nice to have the entity manager return $this in methods like persist and remove, so instead of having this: $em = $this->get('doctrine')->getEntityManager(); One could do this: $em = $this->get('doctrine')->getEntityManager(); It is a small improvement (and perhaps its not the best case to demonstrate it) but it makes using the entity manager more comfortable. |
| Comments |
| Comment by Benjamin Eberlei [ 27/May/11 ] |
|
A fluent interface shouldnt be introduced just for convenience, it makes no sense here semenatically. |
| Comment by David Vega [ 30/May/11 ] |
|
Well, I never spoke of any fluent interface, and method chaining —which can be easily confused with fluent interfaces or vice versa (read the Update at the bottom of http://martinfowler.com/bliki/FluentInterface.html)— is often used for convenience, meaning readability and practicality. So compare: $entity_manager With: $entity_manager->persist($an_entity) It is way less tedious and way more readable, and again, not a fluent interface, just method chaining to improve readability and ease of use. |
| Comment by Benjamin Eberlei [ 30/May/11 ] |
|
No reason to reopen. We made this decision and its final |
[DDC-1157] Remove Cascade doesn't work on proxy object Created: 18/May/11 Updated: 06/Sep/11 Resolved: 06/Sep/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Jonathan Clus | Assignee: | Guilherme Blanco |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Doctrine 2.1 beta |
||
| Description |
|
Hi all, I am a beginner with doctrine, so all my apologize if this is not the place, or if this issue was already report. I posted on doctrine user google group(http://tinyurl.com/6gh49yh), but got no response, asked on mirc channel, not response too. I searched into jira for the same issue, but i don't find. This is my problem: I have a ont-to-one relation between two entities, A and B. A got foreign key to B. I configure delete cascade on A, so i am expected that if A is deleted, B should be too. So this is a forgotten implementation, a bug, or did I make something wrong because what i want to do work perfectly for you ? Thanks for reading. |
| Comments |
| Comment by Guilherme Blanco [ 06/Sep/11 ] |
|
Defining delete cascade means that when B is removed, A is also removed... not the opposite. You need to define cascade= {"remove"}in order to have this working nicely. |
[DDC-1142] Cache affecting Doctrine\ORM\Persisters\BasicEntityPersister::_prepareUpdateData() Created: 10/May/11 Updated: 15/Mar/12 Resolved: 15/Mar/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.4 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | raiz | Assignee: | Benjamin Eberlei |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Environment: |
php 5.3.5, winxp , WampServer 2.1e |
||
| Description |
|
Doctrine\ORM\Persisters\BasicEntityPersister::_prepareUpdateData() Dependand on the prepopulation of $this->_class->associationMappings. Subsequent calls when using memcache wil have $this->_class->associationMappings[$field] NOT set & hence differing behaviour. |
| Comments |
| Comment by Benjamin Eberlei [ 14/May/11 ] |
|
Why have subsequent calls with memcache $this->_class->associationMappings[$field] not set? This should not be happening |
| Comment by Benjamin Eberlei [ 28/Dec/11 ] |
|
note to myself: Maybe a windows + memcache, wampserver issue? |
| Comment by Alexander [ 15/Mar/12 ] |
|
Cannot really reproduce this and no additional feedback was provided. -> close |
[DDC-1114] Association on a non primary key field - fix the commit order Created: 14/Apr/11 Updated: 05/Sep/11 Resolved: 05/Sep/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Daniel Barsotti | Assignee: | Guilherme Blanco |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Environment: |
debian lenny, smyfony2, postgres 8.4 |
||
| Issue Links: |
|
||||||||
| Description |
|
We are trying to create an association which referenced column is not a primary key. The source entity mapping looks like: <entity name="Joiz\HomeBundle\Entity\ShowInstanceTeaser" table="teaser"> The destination entity mapping is: <entity name="Joiz\ShowBundle\Entity\ShowInstance" table="show_instance" repository-class="Joiz\ShowBundle\Entity\ShowInstanceRepository"> <id name="id" column="id" type="integer"> <field name="extid" column="extid" type="string" unique="true" /> <!-- ... snip ... --> </entity> Doctrine will correctly create the tables with the above mapping but the association does not seem to work. When we try to load some data in the tables: $showInst = new ShowInstance(); $teaser = new ShowInstanceTeaser(); This will leave the column "teaser.show_instance_extid" null. Doing the same but using the primary key for the association will work. In a discussion on the #doctrine-dev channel on freenode beberlei explained: <beberlei> ah the problem is probably the CommitOrderCalculator does not know of this foreign key <beberlei> you cannot add foreign keys say through some mapping information in annotations or xml the like |
| Comments |
| Comment by Benjamin Eberlei [ 12/Jul/11 ] |
|
Btw, I don't think its supported to use a non primary id for foreign key matching. I cant tell for sure though since i wasn't responsible to design this part of the Doctrine code. I would strongly suggest not to do this. |
| Comment by Guilherme Blanco [ 05/Sep/11 ] |
|
Any ORM can't be designed to map associations on non-ID fields. Ideally, no IDs would be exposed to user (they should be controlled internally), but since almost everything rely on IDs to be passed this is exposed to the user. Anyway, this ticket is invalid as it's an invalid usage of the ORM tool. |
[DDC-1046] Configurable/overridable code generation templates for entities and repositories classes automatic generation Created: 25/Feb/11 Updated: 11/Mar/12 Resolved: 11/Mar/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | New Feature | Priority: | Major |
| Reporter: | Mykhailo Stadnyk | Assignee: | Benjamin Eberlei |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Initial proposal discussed in doctrine-user groups: http://groups.google.com/group/doctrine-user/browse_thread/thread/10ed814339429c3e?hl=en Required features are: 1. Possibility to override default Doctrine's code generation templates, which are hard-coded for the moment within EntityGenerator & EntityRepositoryGenerator classes Attached pull request with possible implementation is here: https://github.com/doctrine/doctrine2/pull/30 |
| Comments |
| Comment by Benjamin Eberlei [ 25/Feb/11 ] |
|
There are several things I don't like with this change that need to be addressed before I merge this:
|
| Comment by Mykhailo Stadnyk [ 26/Feb/11 ] |
|
Hi, Benjamin! Done and available for review: https://github.com/doctrine/doctrine2/pull/30/files 1. Done. Options dropped, added optional arguments --code-writer="My\Writer\ClassImpl" to orm:generate-entities & orm:generate-repositories commands I've also removed assignment of writer instance via constructor and added setCodeWriter method dedicated for this purpose. From other hand implemented getCodeWriter method will construct a default writer if none was previously set, so both EntityRepositoryGenerator and EntityGenerator are also backward compatible from now. |
| Comment by Mykhailo Stadnyk [ 01/Mar/11 ] |
|
Could I help in any other way? Is there any problem to merge? Best regards, |
| Comment by Benjamin Eberlei [ 01/Mar/11 ] |
|
I just have limited time at the moment, i will merge this in the near future. |
| Comment by Alexander [ 11/Mar/12 ] |
|
The entity generation stuff will hopefully be replaced by a new generation project in the future: Since this is quite an old issue I'll close it. |
[DDC-1020] Do we really need PreUpdateEventArgs::_assertValidField()? Created: 08/Feb/11 Updated: 11/Feb/11 Resolved: 11/Feb/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Jonathan H. Wage | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I am not sure why we need this. I have a situation where we have a preUpdate() listener and the field I want to set the value for is not already in the changeset so _assertValidField() throws an exception. Do we really need this? class Order
{
private $something;
private $tax;
// ...
}
$order = $em->find('Order', 1);
$order->setSomething('test');
$em->flush();
class MyListener
{
public function preUpdate(PreUpdateEventArgs $args)
{
$calculatedTax = 0;
// _assertValidField() in PreUpdateEventArgs throws an exception because
// tag is not already in the changeset. If i hack around it and do $this->tax = 1; or something
// in the contructor of Order then it shows up in the changeset and setNewValue() works
$args->setNewValue('tax', $calculatedTax);
}
}
|
| Comments |
| Comment by Jonathan H. Wage [ 11/Feb/11 ] |
|
Working on an actual test and patch for this. |
| Comment by Jonathan H. Wage [ 11/Feb/11 ] |
|
After discussing this we discovered that you just need to modify the entity and then explicitly recompute the changeset for that document. class DDC1020OrderEventListener
{
public function preUpdate(LifecycleEventArgs $args)
{
$order = $args->getEntity();
$order->tax = 100;
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
$uow->recomputeSingleEntityChangeSet(
$em->getClassMetadata(get_class($order)),
$args->getEntity()
);
}
}
|
[DDC-1013] Possible issue with multiple levels of Mappedsuperclasses and wrong sql table aliases Created: 02/Feb/11 Updated: 14/Aug/11 Resolved: 14/Aug/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.1 |
| Fix Version/s: | 2.2 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Guilherme Blanco |
| Resolution: | Invalid | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Possible issue with multiple levels of Mappedsuperclasses and wrong sql table aliases |
| Comments |
| Comment by Kevin Bond [ 26/Jul/11 ] |
|
Any update on this, is there a work-around? |
| Comment by Benjamin Eberlei [ 26/Jul/11 ] |
|
I could not reproduce this yet, can you provide me with a reproduce case? |
| Comment by Kevin Bond [ 26/Jul/11 ] |
|
https://gist.github.com/1107578 shows my entity inheritance structure: Entity (MappedSuperClass) -> Page -> BaseClassification (MappedSuperClass) -> Species ... SQLSTATE[42S22]: Column not found: 1054 Unknown column 't0.path' in 'where clause' The query being generated is as follows: 'SELECT t1.body AS body2, t1.path AS path3, t1.id AS id4, t1.title AS title5, t1.updated_at AS updated_at6, t1.created_at AS created_at7, t1.alternate_names AS alternate_names8, t1.latin_name AS latin_name9, t1.genus_id AS genus_id10 FROM species t1 WHERE t0.path = ?' that t0 is an alias that does exist. If you need further information, let me know. Thanks. |
| Comment by Guilherme Blanco [ 14/Aug/11 ] |
|
Hi, Your mapping is wrong. Marking this issue as invalid. Reopen if you after your mapping fix the issue still persist. Cheers, |
| Comment by Kevin Bond [ 14/Aug/11 ] |
|
Hmm, not sure what you mean? BaseClassification extends the Page entity... Should BaseClassification not contain all the fields from Page and Species not all the fields from BaseClassification? |
[DDC-949] strange behavior with boolean types when using findOneBy() in a CLI phpunit test Created: 25/Dec/10 Updated: 02/Jan/11 Resolved: 02/Jan/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0.1, 2.1 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Lukas Kahwe | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
I do not see this behavior when running findByOne() calls via the Apache SAPI. No clue really what could possibly cause this. Not sure how to get the error logger to output something in a phpunit test (never really figured out how phpunit supports debugging). Essentially if I run the tests with SQLite the case with 'false' fails and when I run with PostgreSQL the case with 0 fails. Essentially in the fail case I get an instance of $this, just like when I pass: false. Tell me if this report is useless in the current state and then I will work on separating it out into a standalone CLI script without Symfony2 and phpunit. But I dont want to spend more time on this if it isnt necessary. |
| Comments |
| Comment by Benjamin Eberlei [ 28/Dec/10 ] |
|
Cannot reproduce. |
| Comment by Benjamin Eberlei [ 28/Dec/10 ] |
|
Attached simpler testcase for reproduce. |
| Comment by Lukas Kahwe [ 28/Dec/10 ] |
|
further testing shows this issue only exists with false and there I can reproduce it on the CLI and via apache. it seems I am hitting: http://bugs.php.net/bug.php?id=33876 |
| Comment by Lukas Kahwe [ 01/Jan/11 ] |
|
as explained in the previous comment, the issue is caused by "false" and not by "true" as in the test case. |
| Comment by Benjamin Eberlei [ 02/Jan/11 ] |
|
Fixed. This issue occured, because BasicEntityPersister did not pass the PARAM: typehints to the DBAL connection. Adding this fixes the issue with Booleans on PostgreSQL, however I just realized it also exists for Oracle OCI and needs an adjustment in DBAL to be fixable. |
| Comment by Lukas Kahwe [ 02/Jan/11 ] |
|
I am also seeing the issue with SQLite. |
| Comment by Lukas Kahwe [ 02/Jan/11 ] |
|
ok .. i can confirm the issue is fixed on sqlite and postgresql |
[DDC-1408] DQL parser fails to parse alias in select expression named "count" Created: 10/Oct/11 Updated: 16/Oct/11 Resolved: 16/Oct/11 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | DQL |
| Affects Version/s: | 2.1.1 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Aigars Gedroics | Assignee: | Guilherme Blanco |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Environment: |
mysql |
||
| Description |
|
When running DQL SELECT count(u.id) AS count FROM User u I receive error [Doctrine\ORM\Query\QueryException]
[Semantical Error] line 0, col 28 near 'FROM User u': Error: Class 'FROM' is not defined.
because of "COUNT" alias being parsed as aggregate function. Still such alias is valid in MySQL and should be treated as "identifier" following the DQL EBNF (at least I think so). If not fixing this to allow such names being used as aliases, at least should warn developer about this somehow, because the current error is not self descriptive. |
| Comments |
| Comment by Guilherme Blanco [ 16/Oct/11 ] |
|
COUNT is considered a keyword in other drivers, so this issue is not solvable. It's not possible to fix and we already give the hint to the users to not use tokens as identifiers. You're in your will by doing that. |
[DDC-1362] Native SQL with addJoinedEntityResult() causes wrong mapping Created: 05/Sep/11 Updated: 15/Mar/12 Resolved: 15/Mar/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.0.5 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Venkatraman Dhamodaran | Assignee: | Benjamin Eberlei |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Ubuntu |
||
| Attachments: |
|
| Description |
|
Order of fields in the native select query and order of result set mapping should be in the same order, otherwise wrong mapping is happening. I have faced problem with my code. I am explaining the issue with the simple code $sql =" $rsm = new ResultSetMapping; $rsm->addEntityResult('models\User', 'u'); $rsm->addJoinedEntityResult('models\Address', 'a', 'u', 'address'); $rsm->addFieldResult('a', 'aid', 'id'); $query = $this->_em->createNativeQuery($sql, $rsm); As in the code, the select clause column ordering and result set mapping orders are reversed. It causes the wrong mapping as follows The wrong mapping happens as follows user1 => address2 instead of the correct mapping as user1=>address1 |
| Comments |
| Comment by Fabio B. Silva [ 17/Jan/12 ] |
|
hi Venkatraman, I can't reproduce.. i'm attaching a test-case with a working scenario. Thanks |
| Comment by Alexander [ 15/Mar/12 ] |
|
Closing until someone can provide more information. |
[DDC-1303] Adding casts on EntityGenerator's generated setters could improve the Database hitting Created: 29/Jul/11 Updated: 11/Mar/12 Resolved: 11/Mar/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Grégoire Passault | Assignee: | Benjamin Eberlei |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Description |
|
As i mentionned here: https://groups.google.com/d/topic/doctrine-dev/ovDQzb9JM74/discussion Imagine you have some boolean, like "archived", the code that EntityGenerator generated is like: MyEntity.php public function setArchived($archived) { $this->archived = $archived; } Now, imagine I use some forms logics to archive the object, I'll pass "1" to setArchived. So, I think it would be better if Doctrine generates the following: MyEntity.php public function setArchived($archived) { $this->archived = (null === $archived) ? null : (bool)$archived; } |
| Comments |
| Comment by Grégoire Passault [ 29/Jul/11 ] |
|
I wrote it here: The casts are disabled by defaults (in both EntityGenerator and Command line) |
| Comment by Alexander [ 11/Mar/12 ] |
|
The entity generation stuff will be replaced by a new generation project in the future (which is way more flexible): |
[DDC-2094] [GH-488] Fix DDC-2079 Created: 20/Oct/12 Updated: 21/Oct/12 Resolved: 21/Oct/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of FabioBatSilva: Url: https://github.com/doctrine/doctrine2/pull/488 Message: http://www.doctrine-project.org/jira/browse/DDC-2079 |
| Comments |
| Comment by Benjamin Eberlei [ 21/Oct/12 ] |
|
A related Github Pull-Request [GH-488] was closed |
| Comment by Fabio B. Silva [ 21/Oct/12 ] |
|
Merged |
[DDC-2095] [GH-489] Fixed coding standards in the Tools namespace Created: 22/Oct/12 Updated: 04/Nov/12 Resolved: 04/Nov/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of stof: Url: https://github.com/doctrine/doctrine2/pull/489 Message: This also fixes some command exit code in case of failure and removes an unused private method |
| Comments |
| Comment by Benjamin Eberlei [ 03/Nov/12 ] |
|
A related Github Pull-Request [GH-489] was closed |
[DDC-2092] [GH-487] Fix DDC-2069 Created: 20/Oct/12 Updated: 21/Oct/12 Resolved: 21/Oct/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of FabioBatSilva: Url: https://github.com/doctrine/doctrine2/pull/487 Message: http://www.doctrine-project.org/jira/browse/DDC-2069 |
| Comments |
| Comment by Benjamin Eberlei [ 21/Oct/12 ] |
|
A related Github Pull-Request [GH-487] was closed |
| Comment by Fabio B. Silva [ 21/Oct/12 ] |
|
Merged |
[DDC-2074] ManyToManyPersister not found in the chain configured namespaces Created: 12/Oct/12 Updated: 25/Nov/12 Resolved: 25/Nov/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | 2.3.1 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Steffan Harries | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Symfony 2.1 |
||
| Description |
|
The error is: "The class 'Doctrine\ORM\Persisters\ManyToManyPersister' was not found in the chain configured namespaces" Replicate by making an entity which has a property which is self referencing; e.g. http://docs.doctrine-project.org/en/latest/reference/association-mapping.html#many-to-many-self-referencing . For example an Album could be related to any other similar albums. An album entity would have a property 'relatedAlbums' which is an ArrayCollection. Similarly, I could be working on a CMS where any piece of content could be related to any other in order to show a "related content" or "related posts" style list on a web page. Using Symfony 2.1 and a Symfony Form with FormBuilder make sure to use the 'by_reference' => false to call the setter for the property. In the setter for the property: https://gist.github.com/3879169 A similar question has been asked on StackOverflow: http://stackoverflow.com/questions/12077084/doctrine2-manytomany-self-referencing |
| Comments |
| Comment by Benjamin Eberlei [ 12/Oct/12 ] |
|
I need a stacktrace for this error, i have no clue why this happens and where. |
| Comment by Steffan Harries [ 15/Oct/12 ] |
|
Stack Trace: The class 'Doctrine\ORM\Persisters\ManyToManyPersister' was not found in the chain configured namespaces Gedmo\Tree\Entity, Gedmo\Translatable\Entity, MyProject\Bundle\AdminBundle\Entity, MyProject\Bundle\Common\SiteBundle\Entity, MyProject\Bundle\Common\ContentBundle\Entity, FOS\UserBundle\Entity 500 Internal Server Error - MappingException Stack Trace in /opt/local/apache2/htdocs/projects/my-project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php at line 38 at MappingException ::classNotFoundInNamespaces ('Doctrine\ORM\Persisters\ManyToManyPersister', array('Gedmo\Tree\Entity', 'Gedmo\Translatable\Entity', 'MyProject\Bundle\AdminBundle\Entity', 'MyProject\Bundle\Common\SiteBundle\Entity', 'MyProject\Bundle\Common\ContentBundle\Entity', 'FOS\UserBundle\Entity')) |
| Comment by Benjamin Eberlei [ 25/Nov/12 ] |
|
Ok apparently this is fixed |
[DDC-2033] Merge with multiple Associations to the same Entity Created: 17/Sep/12 Updated: 23/Jan/13 Resolved: 23/Jan/13 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | sören jahns | Assignee: | Marco Pivetta |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | merge | ||
| Environment: |
Symfony 2.1.1, Ubuntu, PHP 5.3.5 |
||
| Attachments: |
|
| Description |
|
Let's say we have 2 Entities. User and Group and there's a ManyToMany Assocication and an additional ManyToOne (User as owning side and no inverse). So a User can have as many Groups as he likes and one another with the ManyToOne Association which can be also in the ManyToMany Collection. (Could be the MainGroup or something) I create a User and add a Group(already in DB) and set the same as the ManyToOne and Merge it. Everything works fine as long as the Group in ManyToOne Association is not in the ManyToMany. If I var_dump the merged entity i can already see that one association is empty. It looks like doctrine is writing just one association of that Group preferring which one comes first. So if i change the position of the properties in the class the written association changes, but doctrine never writes both. The reason why I use merge is that I normally store the entity in the session and merge and flush it in another request. But this also happens in the same Request. In the UnitofWork at Line 2050 and 2053 are the responsible doMerge Calls for as CascadeMerge Tagged Associations. If Doctrine gets there in the first place the doMerge for the Group is running through. In the Second call when the Group is again associated with the user the doMerge already exits at line 1658. That's ok but I think there's something missing so doctrine isn't creating the association. The Mentioned Entites are attached |
| Comments |
| Comment by Marco Pivetta [ 23/Jan/13 ] |
|
Duplicate of |
[DDC-1985] Call to undefined method ProxyException::proxyDirectoryNotWritable Created: 16/Aug/12 Updated: 17/Aug/12 Resolved: 17/Aug/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2.3 |
| Fix Version/s: | 2.3 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Mark van der Velden | Assignee: | Guilherme Blanco |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
I think it's fairly self explanatory, didn't supply a patch since I had no idea what text you wanted there PHP Fatal error: Call to undefined method Doctrine\ORM\Proxy\ProxyException::proxyDirectoryNotWritable() in .../orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php on line 193 |
| Comments |
| Comment by Guilherme Blanco [ 17/Aug/12 ] |
|
This issue is already fixed in master |
[DDC-1669] [GH-289] by isanosyan: Preserve camelcase when mapping existing database Created: 28/Feb/12 Updated: 11/Jul/12 Resolved: 11/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Improvement | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of {username}: Url: https://github.com/doctrine/doctrine2/pull/289 Message: CamelCase is now preserved when importing entities from existing database using Symfony's command php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force |
| Comments |
| Comment by Benjamin Eberlei [ 22/Mar/12 ] |
|
A related Github Pull-Request [GH-289] was |
[DDC-1656] fetch mode EXTRA_LAZY does not do a IN(1, 2, 3, ...) merge type query to fetch OneToMany results Created: 17/Feb/12 Updated: 17/Feb/12 Resolved: 17/Feb/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | des hymers | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
Using the fetch mode EXTRA_LAZY does not produce a SQL query to fetch all OneToMany relationship results via a IN(1, 2, 3, ...) type merged query, instead it does one query per row in the result set. First query to obtain all the pages SELECT t0.page_id AS page_id1, t0.name AS name2, t0.text AS text3, t0.url AS url4, t0.revision_id AS revision_id5, t0.owner_id AS owner_id6, t0.is_active AS is_active7 FROM pages t0 then for each row in that result set SELECT t0.attribute_id AS attribute_id1, t0.page_id AS page_id2, t0.key AS key3, t0.value AS value4, t0.page_id AS page_id5 FROM page_attributes t0 WHERE t0.page_id = ? What is desired is a query like this, SELECT t0.attribute_id AS attribute_id1, t0.page_id AS page_id2, t0.key AS key3, t0.value AS value4, t0.page_id AS page_id5 FROM page_attributes t0 WHERE t0.page_id IN(1, 2, 3, ...) to obtain all the attributes for the pages, after the first original page query. |
| Comments |
| Comment by des hymers [ 17/Feb/12 ] |
|
had a typo in the file I uploaded, corrected now |
| Comment by Alexander [ 17/Feb/12 ] |
|
Closed as invalid, because this is the ORM working as intended. First all the PageEntity objects are loaded. Next there is a loop over all the objects, with an inner loop on the "attributes" association. These attributes are lazy loaded for each individual page, hence 1 query for all the pages and n queries for all the attributes of the pages. |
[DDC-1650] PHP 5.3.2 compatibility Created: 13/Feb/12 Updated: 11/Jul/12 Resolved: 11/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Florent Cailhol | Assignee: | Marco Pivetta |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Environment: |
php 5.3.2 |
||
| Description |
|
When triggering travis build under PHP 5.3.2, the build fails. Fatal error: Class '\Doctrine\Tests\DbalTypes\UpperCaseStringType' not found in /home/vagrant/builds/ooflorent/doctrine2/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/Type.php on line 144 Call Stack: 1. {main}() /home/vagrant/.phpenv/versions/5.3.2/bin/phpunit:0
2. PHPUnit_TextUI_Command::main() /home/vagrant/.phpenv/versions/5.3.2/bin/phpunit:46
3. PHPUnit_TextUI_Command->run() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:130
4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:192
5. PHPUnit_Framework_TestSuite->run() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/TextUI/TestRunner.php:325
6. PHPUnit_Framework_TestSuite->run() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/Framework/TestSuite.php:705
7. PHPUnit_Framework_TestSuite->runTest() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/Framework/TestSuite.php:745
8. PHPUnit_Framework_TestCase->run() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/Framework/TestSuite.php:772
9. PHPUnit_Framework_TestResult->run() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/Framework/TestCase.php:751
10. PHPUnit_Framework_TestCase->runBare() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/Framework/TestResult.php:649
11. Doctrine\Tests\ORM\Functional\TypeValueSqlTest->setUp() /home/vagrant/.phpenv/versions/5.3.2/share/pyrus/.pear/php/PHPUnit/Framework/TestCase.php:801
12. Doctrine\Tests\OrmFunctionalTestCase->setUp() /home/vagrant/builds/ooflorent/doctrine2/tests/Doctrine/Tests/ORM/Functional/TypeValueSqlTest.php:
13. Doctrine\ORM\EntityManager->getClassMetadata() /home/vagrant/builds/ooflorent/doctrine2/tests/Doctrine/Tests/OrmFunctionalTestCase.php:272
14. Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor() /home/vagrant/builds/ooflorent/doctrine2/lib/Doctrine/ORM/EntityManager.php:269
15. Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() /home/vagrant/builds/ooflorent/doctrine2/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:178
16. Doctrine\ORM\Mapping\Driver\AnnotationDriver->loadMetadataForClass() /home/vagrant/builds/ooflorent/doctrine2/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:293
17. Doctrine\ORM\Mapping\ClassMetadataInfo->mapField() /home/vagrant/builds/ooflorent/doctrine2/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:327
18. Doctrine\ORM\Mapping\ClassMetadataInfo->_validateAndCompleteFieldMapping() /home/vagrant/builds/ooflorent/doctrine2/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:1735
19. Doctrine\DBAL\Types\Type::getType() /home/vagrant/builds/ooflorent/doctrine2/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php:1074
|
| Comments |
| Comment by Benjamin Eberlei [ 20/Feb/12 ] |
|
Does this only fail exactly with 5.3.2? What could be the issue? |
| Comment by Marco Pivetta [ 03/Apr/12 ] |
|
Also, knowing the travis build url could help |
| Comment by Florent Cailhol [ 06/Apr/12 ] |
|
Sorry about the long inactivity period... |
| Comment by Marco Pivetta [ 08/Jul/12 ] |
|
I think this may be solved.in DBAL by putting a `trim()` at https://github.com/doctrine/dbal/blob/1ca9db4f437797c6bdc04a3a761d61e24150e20b/lib/Doctrine/DBAL/Types/Type.php#L170 |
| Comment by Marco Pivetta [ 10/Jul/12 ] |
|
Couldn't reproduce on 5.3.2, and seems like the build points to a non existing repository (you have deleted it from your github). |
[DDC-1626] Refreshing an entity after disabling a filter has no effect Created: 30/Jan/12 Updated: 30/Jan/12 Resolved: 30/Jan/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Bart van den Burg | Assignee: | Benjamin Eberlei |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The situation: I have a Person with a 1-to-1 relation to User, fetch mode is EAGER. The user has a deleted flag, which in this case is set to true. The filter automatically adds a "deleted = 0" to the join query I wish to fetch the user anyway, so I disable the filter and execute a refresh: $em->getFilters()->disable('soft_delete'); Unfortunately, this doesn't work as the left join part of the query is saved line 971 through 973 in BasicEntityPersister: if ($this->_selectColumnListSql !== null) { if I remove these lines, everything works fine... |
| Comments |
| Comment by Alexander [ 30/Jan/12 ] |
|
I had a short discussion about this. The problem isn't easily solved by the "fix" you provide. It's very complicated to fix it for all use-cases if you already have objects. If you change your filter settings, you should clear the em and refetch your object(s). I'll put a big WARNING about this in the upcoming docs. |
| Comment by Bart van den Burg [ 30/Jan/12 ] |
|
I realise that my fix was not the way to go, it was just a quick fix to show the source of the problem clearing the EM has way too big consequences at the position where I'd have to do it. If the only way to fetch "deleted" objects is by clearing the whole EM, then filters unfortunately are unusable for me. I hope a fix for this will be implemented at some point |
[DDC-1625] proxy initialized when accessing identifier on extending class Created: 30/Jan/12 Updated: 05/Feb/12 Resolved: 05/Feb/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.2, Git Master |
| Fix Version/s: | 2.2.1 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Miha Vrhovnik | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
The proxy is always initialized when the entity is extending another class and that parent class has get<IDENTIFIER> method |
| Comments |
| Comment by Miha Vrhovnik [ 30/Jan/12 ] |
| Comment by Alexander [ 30/Jan/12 ] |
|
Re-opening this ticket as a reminder for Benjamin to backport the fix to 2.2. |
| Comment by Benjamin Eberlei [ 05/Feb/12 ] |
|
Merged into 2.2, See |
[DDC-1591] Paginator: ResultVariable cannot be used in HavingClause Created: 09/Jan/12 Updated: 15/Mar/12 Resolved: 15/Mar/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | Git Master |
| Fix Version/s: | 2.3 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Christian Raue | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Using the QueryBuilder, I'm getting the message Notice: Undefined index: distance in vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php line 2128 when trying to add a "having" clause for the field "distance", which is defined in the "select" part of the statement: $queryBuilder
->select('myEntity, MY_FUNCTION() AS distance')
->having('distance <= 10')
;
|
| Comments |
| Comment by Fabio B. Silva [ 14/Jan/12 ] |
|
Christian, I couldn't reproduce. Can you give more details ? Thanks. |
| Comment by Christian Raue [ 15/Jan/12 ] |
|
I tried it again and found out that it could also be an issue in https://github.com/whiteoctober/Pagerfanta rather in Doctrine itself because my query is passed to that pager to show a sliced result. Maybe that issue could already be resolved by https://github.com/whiteoctober/Pagerfanta/pull/46. Will give it a try... |
| Comment by Christian Raue [ 15/Jan/12 ] |
|
In fact, applying that patch made the query work. So this is not a Doctrine issue. |
| Comment by Christian Raue [ 10/Feb/12 ] |
|
Since the PR mentioned was not merged and Doctrine's pagination is used now, the issue still exists and I cannot use a result variable in a "having" clause. But I'd like to. |
| Comment by Christophe Coevoet [ 10/Feb/12 ] |
|
This ticket is indeed invalid as it is talking about the query builder. Please open a dedicated ticket for the pagination issue |
| Comment by Christian Raue [ 10/Feb/12 ] |
|
But I am using the QueryBuilder and then passing the query to a DoctrineORMAdapter instance. The error message didn't change, just the line number: Notice: Undefined index: distance in vendor\doctrine\lib\Doctrine\ORM\Query\SqlWalker.php line 2142 But I can confirm that this error doesn't occur when not using a paginator. How to continue? |
| Comment by Benjamin Eberlei [ 10/Feb/12 ] |
|
Which paginator are you using? |
| Comment by Christian Raue [ 10/Feb/12 ] |
| Comment by Benjamin Eberlei [ 20/Feb/12 ] |
|
Renamed and assigned issue. |
| Comment by Alexander [ 15/Mar/12 ] |
|
Fixed as sander was kind enough to resubmit the code to the doctrine2 repository now instead: |
[DDC-1948] Lazy Loading on Many To One association does not work Created: 26/Jul/12 Updated: 21/Feb/13 Resolved: 21/Feb/13 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.1.7 |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Julien AUBIN | Assignee: | Marco Pivetta |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Create a many to one relationship with lazy loading as exposed there : Notice that the relationship does not load while it should. The problem is always reproducible. |
| Comments |
| Comment by Benjamin Eberlei [ 29/Jul/12 ] |
|
I need more information. The mapping of both entities, and a \Doctrine\Common\Utils\Debug::dump() of the $source entity when its a proxy. Also it would be helpful to have an SQL log which shows the queries executed by your example. Do you use any listeners? |
| Comment by Marco Pivetta [ 21/Feb/13 ] |
|
Closing as incomplete. Please test this with latest master before eventually re-opening |
[DDC-1936] [GH-404] DDC-1933 - Fixing cloning of QueryBuilder and adding related tests Created: 19/Jul/12 Updated: 23/Jul/12 Resolved: 23/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Marco Pivetta |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of Ocramius: Url: https://github.com/doctrine/doctrine2/pull/404 Message: This PR fixes |
| Comments |
| Comment by Benjamin Eberlei [ 23/Jul/12 ] |
|
A related Github Pull-Request [GH-404] was closed |
[DDC-1930] [GH-401] Add Doctrine\Tests in composer autoload Created: 17/Jul/12 Updated: 17/Jul/12 Resolved: 17/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of cedriclombardot: Url: https://github.com/doctrine/doctrine2/pull/401 Message: |
| Comments |
| Comment by Benjamin Eberlei [ 17/Jul/12 ] |
|
A related Github Pull-Request [GH-401] was closed |
[DDC-1933] Problem with parameters when clone Doctrine\ORM\QueryBuilder Created: 18/Jul/12 Updated: 23/Jul/12 Resolved: 23/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | 2.3, Git Master |
| Fix Version/s: | Git Master |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Gandzy Ghennady | Assignee: | Marco Pivetta |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Hi, here problem with cloning \Doctrine\ORM\QueryBuilder Example $queryBuilder = new QueryBuilder($em); $queryBuilder->setParameter('parameter1', 'value1'); $copy = clone $queryBuilder; $copy->setParameter('parameter2', 'value2'); count($queryBuilder->getParameters()) // equals 2 //expects 1 Solution: QueryBuilder public function __clone { ...... $this->parameters = clone $this->parameters; } |
| Comments |
| Comment by Marco Pivetta [ 18/Jul/12 ] |
|
Is `$copy = clone $queryBuilder();` a typo? |
| Comment by Gandzy Ghennady [ 18/Jul/12 ] |
|
Sorry, this is a typo, was meant: $copy = clone $queryBuilder; |
| Comment by Marco Pivetta [ 20/Jul/12 ] |
|
This is being handled at |
| Comment by Gandzy Ghennady [ 20/Jul/12 ] |
|
Hi. Thanks for the quick response. I looked at the changes, and have a question: whether you need to reset the parameters when cloning? Thus broken backward compatibility with versions <2.3. |
| Comment by Marco Pivetta [ 20/Jul/12 ] |
|
Actually, I just implemented your expected behaviour (see tests), which is compatible with what the `AbstractQuery` does. It can also be done the other way around, waiting for feedback by Benjamin Eberlei |
| Comment by Marco Pivetta [ 20/Jul/12 ] |
|
Ah, nevermind. You're right. Will change my code |
[DDC-1929] [GH-400] Changed commands to use command.name in the help Created: 16/Jul/12 Updated: 23/Jul/12 Resolved: 23/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of stof: Url: https://github.com/doctrine/doctrine2/pull/400 Message: The current code does not work for child classes: it gets the name too early as the child has not changed it yet at this point. using ``%command;name%`` replaces it only when the help needs to be displayed. |
| Comments |
| Comment by Benjamin Eberlei [ 23/Jul/12 ] |
|
A related Github Pull-Request [GH-400] was closed |
[DDC-1922] [GH-399] Fix phpdocs Created: 11/Jul/12 Updated: 11/Jul/12 Resolved: 11/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of Adel-E: Url: https://github.com/doctrine/doctrine2/pull/399 Message: |
| Comments |
| Comment by Benjamin Eberlei [ 11/Jul/12 ] |
|
A related Github Pull-Request [GH-399] was closed |
[DDC-1919] Doctrine fails to escape entity with reserved name in various situations Created: 10/Jul/12 Updated: 19/Jul/12 Resolved: 11/Jul/12 |
|
| Status: | Closed |
| Project: | Doctrine 2 - ORM |
| Component/s: | None |
| Affects Version/s: | 2.2 |
| Fix Version/s: | 2.3, Git Master |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Klaus Silveira | Assignee: | Benjamin Eberlei |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | None | ||
| Environment: |
MySQL |
||
| Description |
|
I have submitted a PR here, fixing part of this issue: https://github.com/doctrine/dbal/pull/166 However, it fails when UPDATE or INSERT is used. I'm using a very simple, and common, entity name: Group. Doctrine is failing to escape this in various situations, causing queries to fail in MySQL due to reserved keywords. |
| Comments |
| Comment by Marco Pivetta [ 11/Jul/12 ] |
|
Can you try using the quoting strategy in master? By defining an '@Table(name="`Group`")' on your entity you should be able to fix this issue by yourself... Anyway, this is only available in latest master. |
| Comment by Klaus Silveira [ 11/Jul/12 ] |
|
That hack, of course, fixes the problem. Howe |