Skip to content

Render entire statement after applying sort. #3264

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.x-3263-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data JPA Parent</name>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-envers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-envers</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.x-3263-SNAPSHOT</version>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.x-3263-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-jpa-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.x-3263-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.x-3263-SNAPSHOT</version>

<name>Spring Data JPA</name>
<description>Spring Data module for JPA repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa-parent</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.3.x-3263-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public String applySorting(Sort sort, @Nullable String alias) {

selectBody.getOrderByElements().addAll(orderByElements);

return selectBody.toString();
return selectStatement.toString();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ void findsExistingOrderByIndependentOfCase() {
assertThat(query).endsWithIgnoringCase("ORDER BY p.firstname, p.lastname asc");
}

@Test // GH-3263
void doesNotDropWithExpressionWhenApplySort() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to use Sorting instead of Sort for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks @quaff - additionally I'm not happy with the doesNotDrop part. will rename the method.


StringQuery query = new StringQuery("WITH all_projects AS (SELECT * FROM projects) SELECT * FROM all_projects p",
true);

assertThat(getEnhancer(query).applySorting(Sort.by("name"), "p")) //
.startsWithIgnoringCase("WITH all_projects AS (SELECT * FROM projects)")
.endsWithIgnoringCase("ORDER BY p.name ASC");
}

@Test // GH-2812
void createCountQueryFromDeleteQuery() {

Expand Down