Skip to content

Commit

Permalink
replace list of attributes instead of looking for the string " from "
Browse files Browse the repository at this point in the history
when using derived attributes that contain " from " the replacement would fail
  • Loading branch information
darkv committed Aug 20, 2012
1 parent dd68c9b commit dd370d8
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ public int rowCountForFetchSpecification(EOEditingContext ec, EOFetchSpecificati

EOSQLExpression sqlExpression = sqlExpressionForFetchSpecification(ec, spec, 0, -1);
String statement = sqlExpression.statement();
int index = statement.toLowerCase().indexOf(" from ");
String listString = sqlExpression.listString();

String countExpression;
if (spec.usesDistinct()) {
Expand All @@ -1154,7 +1154,7 @@ public int rowCountForFetchSpecification(EOEditingContext ec, EOFetchSpecificati
else {
countExpression = "count(*) ";
}
statement = (new StringBuilder()).append("select ").append(countExpression).append(statement.substring(index, statement.length())).toString();
statement = statement.replace(listString, countExpression);
sqlExpression.setStatement(statement);
sql = statement;
result = ERXEOAccessUtilities.rawRowsForSQLExpression(ec, model.name(), sqlExpression);
Expand Down

0 comments on commit dd370d8

Please sign in to comment.