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

Fixed issue when paginator orders by a subselect expression #1463

Merged
merged 2 commits into from
Aug 4, 2015

Conversation

vaeryn-uk
Copy link
Contributor

On platforms that support the ROW_NUMBER() OVER() function, we've found issues when ordering by a subselect expression. Have included a test demonstrating the problem that was failing with a syntax error under Postgres:

Caused by
PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "SELECT"
LINE 1: ...d = c0_.id) AS sclr_4, ROW_NUMBER() OVER(ORDER BY SELECT MAX...

@doctrinebot
Copy link

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-3831

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

@vaeryn-uk
Copy link
Contributor Author

I think the coverage drop is down to the change not running under SQLite. Running the tests under postgres, this change is definitely covered.

@Ocramius
Copy link
Member

@Ehimen that's alright, we should rather merge the coverage in future. Thanks!

@@ -1093,6 +1093,10 @@ public function walkOrderByItem($orderByItem)

$this->orderedColumnsMap[$sql] = $type;

if ($expr instanceof Query\AST\Subselect) {
$sql = "($sql)";
Copy link
Member

Choose a reason for hiding this comment

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

Use explicit string concatenation here, please. Eventually simply return early

@vaeryn-uk
Copy link
Contributor Author

Thanks @Ocramius! I've updated with some changes. Are these what you had in mind?

@Ocramius Ocramius self-assigned this Jul 17, 2015
@billschaller billschaller assigned billschaller and unassigned Ocramius Aug 4, 2015
billschaller pushed a commit that referenced this pull request Aug 4, 2015
Fixed issue when paginator orders by a subselect expression
@billschaller billschaller merged commit f88896c into doctrine:master Aug 4, 2015
billschaller pushed a commit that referenced this pull request Aug 4, 2015
Fixed issue when paginator orders by a subselect expression
Conflicts:
	tests/Doctrine/Tests/ORM/Tools/Pagination/LimitSubqueryOutputWalkerTest.php
@vaeryn-uk vaeryn-uk deleted the paginate-order-by-subselect branch September 2, 2015 12:15
@lcobucci lcobucci added this to the 2.6.0 milestone Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants