diff --git a/src/main/java/com/samskivert/depot/Funcs.java b/src/main/java/com/samskivert/depot/Funcs.java index e40076a..9cb415f 100644 --- a/src/main/java/com/samskivert/depot/Funcs.java +++ b/src/main/java/com/samskivert/depot/Funcs.java @@ -53,6 +53,15 @@ public class Funcs return new Average(expr, true); } + /** + * Creates an aggregate expression that counts the number of rows that match the other clauses + * in this query. + */ + public static FluentExp countStar () + { + return new Count(Exps.literal("*")); + } + /** * Creates an aggregate expression that counts the number of rows from the supplied * expression. This would usually be used in a FieldOverride and supplied with a ColumnExp. diff --git a/src/main/java/com/samskivert/depot/Query.java b/src/main/java/com/samskivert/depot/Query.java index 0e39019..725f2b2 100644 --- a/src/main/java/com/samskivert/depot/Query.java +++ b/src/main/java/com/samskivert/depot/Query.java @@ -373,7 +373,7 @@ public class Query */ public int selectCount () { - checkState(_groupBy == null, "Do you mean to select(Funcs.count(Exps.literal(\"*\")))?"); + checkState(_groupBy == null, "Do you mean to select(Funcs.countStar())?"); _fromOverride = new FromOverride(_pclass); return _repo.load(CountRecord.class, _cache, getClauseArray()).count; }