Fix count query creation for simple select.
Closes: #3324 Original Pull Request: #3325
This commit is contained in:
@@ -81,6 +81,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Vladislav Yukharin
|
||||
* @author Chris Fraser
|
||||
* @author Donghun Shin
|
||||
* @author Pranav HS
|
||||
*/
|
||||
public abstract class QueryUtils {
|
||||
|
||||
@@ -156,7 +157,7 @@ public abstract class QueryUtils {
|
||||
builder.append("\\s*");
|
||||
builder.append("(select\\s+((distinct)?((?s).+?)?)\\s+)?(from\\s+");
|
||||
builder.append(IDENTIFIER);
|
||||
builder.append("(?:\\s+as)?\\s+)");
|
||||
builder.append("(?:\\s+as)?\\s*)");
|
||||
builder.append(IDENTIFIER_GROUP);
|
||||
builder.append("(.*)");
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.data.jpa.domain.JpaSort;
|
||||
* @author Chris Fraser
|
||||
* @author Michał Pachucki
|
||||
* @author Erik Pellizzon
|
||||
* @author Pranav HS
|
||||
*/
|
||||
class QueryUtilsUnitTests {
|
||||
|
||||
@@ -934,4 +935,10 @@ class QueryUtilsUnitTests {
|
||||
where name like :name
|
||||
""", arg))).containsExactly("points");
|
||||
}
|
||||
|
||||
@Test // GH-3324
|
||||
void createCountQueryForSimpleQuery(){
|
||||
String originalQuery = "select * from User";
|
||||
assertCountQuery(originalQuery,"select count(*) from User");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user