forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 3.1.x: Adjust PHPBench mocks Set column length explicitly (doctrine#11393) Add missing import Remove unused variable (doctrine#11391) Fixed proxy initialization for EnumReflectionProperty Remove older versions from the docs (doctrine#11383) [Documentation] Removing "Doctrine Mapping Types" ... (doctrine#11384) [doctrineGH-11185] Bugfix: do not use collection batch loading for indexBy assocations. (doctrine#11380) Improve lazy ghost performance by avoiding self-referencing closure. (doctrine#11376) Remove outdated git metadata files (doctrine#11362) Switch join columns around, otherwise index doesnt match Key on fk Fix entities and mapping. Minor code style fix in AbstractRemoteControl Do not schedule batch loading for target classes with composite identifier. Cleanup tests not to use model sets. provides a test case for github issue 11154
- Loading branch information
Showing
23 changed files
with
461 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/Tests/Models/EagerFetchedCompositeOneToMany/RootEntity.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\EagerFetchedCompositeOneToMany; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
#[ORM\Table(name: 'eager_composite_join_root')] | ||
class RootEntity | ||
{ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer', nullable: false)] | ||
private int|null $id = null; | ||
|
||
#[ORM\Id] | ||
#[ORM\Column(type: 'string', nullable: false, name: 'other_key', length: 42)] | ||
private string $otherKey; | ||
|
||
/** @var Collection<int, SecondLevel> */ | ||
#[ORM\OneToMany(mappedBy: 'root', targetEntity: SecondLevel::class, fetch: 'EAGER')] | ||
private Collection $secondLevel; | ||
|
||
public function __construct(int $id, string $other) | ||
{ | ||
$this->otherKey = $other; | ||
$this->secondLevel = new ArrayCollection(); | ||
$this->id = $id; | ||
} | ||
|
||
public function getId(): int|null | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getOtherKey(): string | ||
{ | ||
return $this->otherKey; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
tests/Tests/Models/EagerFetchedCompositeOneToMany/SecondLevel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Models\EagerFetchedCompositeOneToMany; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ORM\Entity] | ||
#[ORM\Table(name: 'eager_composite_join_second_level')] | ||
#[ORM\Index(name: 'root_other_key_idx', columns: ['root_other_key', 'root_id'])] | ||
class SecondLevel | ||
{ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer', nullable: false)] | ||
private int|null $upperId; | ||
|
||
#[ORM\Id] | ||
#[ORM\Column(type: 'string', nullable: false, name: 'other_key')] | ||
private string $otherKey; | ||
|
||
#[ORM\ManyToOne(targetEntity: RootEntity::class, inversedBy: 'secondLevel')] | ||
#[ORM\JoinColumn(name: 'root_id', referencedColumnName: 'id')] | ||
#[ORM\JoinColumn(name: 'root_other_key', referencedColumnName: 'other_key')] | ||
private RootEntity $root; | ||
|
||
public function __construct(RootEntity $upper) | ||
{ | ||
$this->upperId = $upper->getId(); | ||
$this->otherKey = $upper->getOtherKey(); | ||
$this->root = $upper; | ||
} | ||
|
||
public function getId(): int|null | ||
{ | ||
return $this->id; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/Tests/ORM/Functional/EagerFetchOneToManyWithCompositeKeyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\ORM\Functional; | ||
|
||
use Doctrine\Tests\Models\EagerFetchedCompositeOneToMany\RootEntity; | ||
use Doctrine\Tests\Models\EagerFetchedCompositeOneToMany\SecondLevel; | ||
use Doctrine\Tests\OrmFunctionalTestCase; | ||
|
||
final class EagerFetchOneToManyWithCompositeKeyTest extends OrmFunctionalTestCase | ||
{ | ||
/** @ticket 11154 */ | ||
public function testItDoesNotThrowAnExceptionWhenTriggeringALoad(): void | ||
{ | ||
$this->setUpEntitySchema([RootEntity::class, SecondLevel::class]); | ||
|
||
$a1 = new RootEntity(1, 'A'); | ||
|
||
$this->_em->persist($a1); | ||
$this->_em->flush(); | ||
|
||
$this->_em->clear(); | ||
|
||
self::assertCount(1, $this->_em->getRepository(RootEntity::class)->findAll()); | ||
} | ||
} |
Oops, something went wrong.