Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Failing test for an ORDER BY that is INNER JOINed in a subquery#1267

Closed
austinsmorris wants to merge 1 commit into
doctrine:masterfrom
austinsmorris:subquery-orderby
Closed

Failing test for an ORDER BY that is INNER JOINed in a subquery#1267
austinsmorris wants to merge 1 commit into
doctrine:masterfrom
austinsmorris:subquery-orderby

Conversation

@austinsmorris
Copy link
Copy Markdown
Contributor

A failing test case to demonstrate a problem with #1220.

cc: @Ocramius @zeroedin-bill, @mvrhov, @stof, @brianium, @mrkrstphr

@doctrinebot
Copy link
Copy Markdown

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3519

We use Jira to track the state of pull requests and the versions they got
included in.

@billschaller
Copy link
Copy Markdown
Member

Thanks - I will take a look at this.

@stof
Copy link
Copy Markdown
Member

stof commented Jan 19, 2015

IMO, we should not only have SQL generation tests for the pagination (because nothing tells us that the asserted SQL is the right one). We should have functional tests for the pagination, ensuring that the queries are working when running them in the DB. What do you think @Ocramius @deeky666 ?

@billschaller
Copy link
Copy Markdown
Member

@Ocramius @stof I'm not entirely sure how best to fix this. I think if an orderBy clause references an identifier for a joined table, the simple solution would be to also ensure that the query is fetch joining it. But that could have performance implications.

The alternative I think would be to add any orderBy expressions not matched in the select list as hidden aliased columns... But I am not sure how best to approach that either.

Thoughts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you pin down which bit strips a1_.name?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a1_.name is not being output in the select list when LimitSubqueryOutputWalker calls $innerSql = parent::walkSelectStatement($AST);

So either it would need to be added to the select clause in the AST somehow, or it would have to be inserted after the AST is materialized to SQL.

@deeky666
Copy link
Copy Markdown
Member

@stof agree. Functional tests around ordering make totally sense IMO as it gives us more safety that the rather complex SQL also works in the end. 👍

@brianium
Copy link
Copy Markdown

@stof @deeky666 I think the functional tests are a great idea. We can see from the generated SQL that it won't work, but it was our DB crying at @austinsmorris and myself that tipped us off to the problem in the first place.

@billschaller
Copy link
Copy Markdown
Member

@stof @deeky666 @brianium Yes, functional tests would especially help highlight issues on platforms that have unhappy ORDER/LIMIT situations. Cough SQLServer cough

@mrkrstphr
Copy link
Copy Markdown
Contributor

Can we revert the original PR that caused this in the meantime? Usage in MySQL and maybe PostgreSQL + Oracle is now broke for a change that was meant to fix SQL Server. I'm sure SQL Server has a pretty small market share of Doctrine usage.

@Ocramius
Copy link
Copy Markdown
Member

Agreed with that.

Please clean up the test code and open a new PR with the actual "final"
result after this is fixed (may change the test or introduce a new one).

If you want, you can include the merge revert commit yourself: otherwise
I'll do it while merging this one.

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 20 January 2015 at 16:21, Kristopher Wilson [email protected]
wrote:

Can we revert the original PR that caused this in the meantime? Usage in
MySQL and maybe PostgreSQL + Oracle is now broke for a change that was
meant to fix SQL Server. I'm sure SQL Server has a pretty small market
share of Doctrine usage.


Reply to this email directly or view it on GitHub
#1267 (comment).

@austinsmorris
Copy link
Copy Markdown
Contributor Author

@Ocramius, test is cleaned up. It should pass once #1220 is reverted.

Thanks!

@Ocramius
Copy link
Copy Markdown
Member

Moved to #1283 - please review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants