Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.4] PHQL DISTINCT does not work for my case due to inappropriate implicit join #10705

Closed
dschissler opened this issue Jul 22, 2015 · 8 comments

Comments

@dschissler
Copy link
Contributor

Between bugs #10526 and #10507 I'm tempted to remove all of the assigned relationships to severals core models that make up all of the interesting parts of my user data and to only use the assigned relationships for the mundane admin related models.

There is no way to get the phql below to work with the joining as it is now. I need to be able to specify that Placement is joining against SuperRecord and not Record.

        $phql = <<<PHQL
SELECT DISTINCT Record.*
FROM $Record Record
LEFT JOIN $Type Type ON Type.recordsId = Record.id
LEFT JOIN $Attribute Attribute ON Attribute.recordsId = Record.id
... conditions
AND
EXISTS (
  SELECT SuperRecord.*
  FROM $Record SuperRecord
  LEFT JOIN $Placement Placement ON Placement.setId = SuperRecord.id
... conditions
)
PHQL;

In my case I actually have two assigned relationships between Placement and Record (so another edge case) and I get this error message: There is more than one relation between models 'Webird\Data\Record' and 'placement', the join must be done using an alias, when preparing: SELECT DISTINCT Record.*. Ok, but aliases are very broken when things start getting complicated (mostly I guess due to #10526) and the forced implicit joins.

I think a more comprehensive rework of the joining and aliases is necessary but for now I've created a more simple bug #10704 to let Phalcon get out of the way as people push the ORM into strange database specific use cases.

@dschissler

This comment was marked as abuse.

@dschissler

This comment was marked as abuse.

@dschissler

This comment was marked as abuse.

@dschissler

This comment was marked as abuse.

@dschissler

This comment was marked as abuse.

andresgutierrez added a commit that referenced this issue Aug 5, 2015
Fix nested SELECT bug #10705, implemented feature #10704 ability to disable implicit joins for query.
@andresgutierrez
Copy link
Contributor

@dschissler Can you please close this issue?

@dschissler

This comment was marked as abuse.

@dschissler

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants