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

DDC-736: Nasty ordering issue with fetch-joins #5249

Closed
doctrinebot opened this issue Aug 7, 2010 · 9 comments
Closed

DDC-736: Nasty ordering issue with fetch-joins #5249

doctrinebot opened this issue Aug 7, 2010 · 9 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user romanb:

Will not work correctly:

select c, ca from Cart ca join ca.customer c

Works correctly:

select ca, c from Cart ca join ca.customer c

In the first case the ordering of the DQL aliases causes associations to be skipped during hydration.

@doctrinebot
Copy link
Author

@doctrinebot
Copy link
Author

Comment created by romanb:

Scheduling for RC1.

@doctrinebot
Copy link
Author

Comment created by mitmaro:

If anyone is getting issues with missing or incorrectly ordered relations it may be caused by this bug.

Would it be possible to put a note in the documentation to ensure the order of the select clause must match that of the joins. I just spent 2 days trying to figure out why the data being returned was incorrect.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Patch that solves this problem. What does it do?

Two additional instance variables are needed, one for the order of the AliasIdentificationVariables and one for a IdentVariable => SelectExpression lookup map.

Inside parse() a reordering is done right before the SQL Walkers are created. This is only done if there is more than one Identification variable in the select expressions, otherwise its not necessary.

The reordering iterates in order of the alias identification variables, grabs the expression from the select expressions and appends it to them. This way it is guaranteed that the expressions are ordered correctly.

SELECT a, b, c.foo, count(d.bar) FROM B b JOIN b.a a JOIN ...

becomes:

SELECT c.foo, count(d.bar), b, a FROM ...

Roman do you think this is viable? See the patch for more details ;)

@doctrinebot
Copy link
Author

Comment created by romanb:

Attached simplified patch.

@doctrinebot
Copy link
Author

Comment created by @beberlei:

Fixed.

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot
Copy link
Author

Comment created by hype:

I think that this patch breaks modifying the select clause in custom tree walkers because walking the select clause will be done after the $_identVariableExpressions array is populated. Reordering the identification variables will then override the modified select clause.

@doctrinebot doctrinebot added this to the 2.0-RC1 milestone Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@doctrinebot
Copy link
Author

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

No branches or pull requests

2 participants