Skip to content

[doctrine2] canSeeInRepository Fails with sub params #4169

@plusdepseudo

Description

@plusdepseudo

What are you trying to achieve?

$I->canSeeInRepository(Address::class, [ 'tags' => [ 'code' => 'perso'], 'references' => ['person' => ['slug' => 'test-bob']]]);

An Address as many Tags, and many References which as a relation to one Person.

  • tags criteria works fine alone: only one array
  • but references doesn't work properly: array within an array

What do you get instead?

It fails with exception message:
Class '' does not exist

Details

  • Codeception version: v2.2.10
  • PHP Version: 5.6
  • Operating System: MacOs
  • Installation type: Composer
  • List of installed packages (composer show)

The problem is in function:
protected function buildAssociationQuery($qb, $assoc, $alias, $params)

Line 412:
if ($map = array_key_exists($key, $data->associationMappings)) {
Should be:

if (array_key_exists($key, $data->associationMappings)) {
    $map = $data->associationMappings[$key];

Line 417: (where start the recursion)
$this->buildAssociationQuery($qb, $map['targetEntity'], $column, $v);
Should be:
$this->buildAssociationQuery($qb, $map['targetEntity'], $key, $val);

Don't know if I misunderstand usage and if not, if this fix breaks compatibility.
Regards,
Cyril

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions