Skip to content

Commit

Permalink
doctrine#11694 - update to 4.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dbannik committed Oct 23, 2024
1 parent a247510 commit 5df2f9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 45 deletions.
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 5df2f9f

Please sign in to comment.