K-Phoen / rulerz

Powerful implementation of the Specification pattern in PHP
MIT License
872 stars 97 forks source link

Alias Conflict with Doctrine Auto Join #79

Closed bobdercole closed 7 years ago

bobdercole commented 7 years ago

Hello,

I am trying to filter entities with the DoctrineOrm target. I've ran into a very particular issue where the auto join code attempts re-use an already defined alias, resulting in a Doctrine QueryException. I am using the latest version (0.20.4) of RulerZ. Here are the conditions in which this occurs:

Here is a simple example of the association map:

When I filter on the user group owner id and the user place owner id, the auto join code assigns both associations the same alias.

I've narrowed the culprit down to this line. I found that adding more specificity to the alias name resolves the issue. For example, I've done the following as a workaround:

$alias = sprintf('_%d_%s', count($this->knownEntities, COUNT_RECURSIVE), $dimension);

Let me know your thoughts. I can open a pull request, but I'm not sure if this is the best fix.

K-Phoen commented 7 years ago

The proposed fix seems plausible to me :)

In the absence of tests for this class, I won't ask you to write some (note to self: this class really needs to be tested…).

I'll trust you when you say it works in your application. If the tests are still green, I will test in my applications that it doesn't break anything and merge your PR.

P.S : thanks for this really detailed issue 👍

Shandur commented 7 years ago

@K-Phoen Is it supposed to be merged?