Skip to content

Commit

Permalink
doctrine#11694 - update to 3.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dbannik committed Oct 23, 2024
1 parent 61385f6 commit 6a25058
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 48 deletions.
3 changes: 1 addition & 2 deletions src/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ class BasicEntityPersister implements EntityPersister
private readonly CachedPersisterContext $limitsHandlingContext;
private readonly CachedPersisterContext $noLimitsContext;

/** @var ?string */
private $filterHash = null;
private string|null $filterHash = null;

/**
* Initializes a new <tt>BasicEntityPersister</tt> that uses the given EntityManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testUseQueryBuilder(): void

['companyA' => $companyA, 'companyB' => $companyB] = $this->prepareData();

$getOrderByIdCache = function (int $orderId): ?Order {
$getOrderByIdCache = function (int $orderId): Order|null {
return $this->_em->createQueryBuilder()
->select('orderMaster, user')
->from(Order::class, 'orderMaster')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

class CompanySQLFilter extends SQLFilter
{
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias): string
public function addFilterConstraint(ClassMetadata $targetEntity, string $targetTableAlias): string
{
if ($targetEntity->getName() === User::class) {
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']['fieldName'], $this->getParameter('company'));
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']->fieldName, $this->getParameter('company'));
}

if ($targetEntity->getName() === Order::class) {
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']['fieldName'], $this->getParameter('company'));
return sprintf('%s.%s = %s', $targetTableAlias, $targetEntity->fieldMappings['company']->fieldName, $this->getParameter('company'));
}

return '';
Expand Down
34 changes: 10 additions & 24 deletions tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilter/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,20 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="Order_Master")
*/
#[ORM\Entity]
#[ORM\Table('Order_Master')]
class Order
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int
*/
public $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
public int $id;

/**
* @ORM\Column(type="string")
*
* @var string
*/
public $company;
#[ORM\Column(type: 'string')]
public string $company;

/**
* @ORM\ManyToOne(targetEntity="User", fetch="EAGER")
*
* @var User
*/
public $user;
#[ORM\ManyToOne(targetEntity: User::class, fetch: 'EAGER')]
public User $user;

public function __construct(User $user)
{
Expand Down
26 changes: 8 additions & 18 deletions tests/Tests/ORM/Functional/Ticket/SwitchContextWithFilter/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,17 @@

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="User_Master")
*/
#[ORM\Entity]
#[ORM\Table('User_Master')]
class User
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var int
*/
public $id;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
public int $id;

/**
* @ORM\Column(type="string")
*
* @var string
*/
public $company;
#[ORM\Column(type: 'string')]
public string $company;

public function __construct(string $company)
{
Expand Down

0 comments on commit 6a25058

Please sign in to comment.