Skip to content

Commit

Permalink
Fix casing bug in JDBC paging list
Browse files Browse the repository at this point in the history
[#113200357] https://www.pivotaltracker.com/story/show/113200357

Signed-off-by: Madhura Bhave <mbhave@pivotal.io>
  • Loading branch information
Jeremy Coffield authored and cf-identity committed Feb 10, 2016
1 parent 7f477fe commit 6998f07
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -104,10 +104,12 @@ public List<E> subList(int fromIndex, int toIndex) {
}

private String getCountSql(String sql) {
String result = sql.toLowerCase().replaceAll("select (.*?) from (.*)", "select count(*) from $2");
if (result.contains("order by")) {
result = result.substring(0, result.lastIndexOf("order by"));
String result = sql.replaceAll("(?i)select (.*?) from (.*)", "select count(*) from $2");
int orderByPos = result.toLowerCase().lastIndexOf("order by");
if (orderByPos >= 0) {
result = result.substring(0, orderByPos);
}

return result;
}

Expand Down

0 comments on commit 6998f07

Please sign in to comment.