Permalink
Browse files

Adds support for GROUP BY in SELECT

  • Loading branch information...
1 parent a33294e commit c5db7a111c7c4484720d6886073bdd267f6fe2ab @yrashk committed Jul 7, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/queries/select.ex
View
9 lib/queries/select.ex
@@ -28,9 +28,16 @@ defrecord ExQL.Select, [fields: :*,
end
end
+ def statement(:group, query) do
+ case group(query) do
+ [] -> nil
+ group_by -> ["GROUP BY", ExQL.Expression.join(group_by, :raw, ", ")]
+ end
+ end
+
def statement(query) do
ExQL.Utils.space(
["SELECT", statement(:modifiers, query), statement(:fields, query),
- statement(:from, query), statement(:where, query)])
+ statement(:from, query), statement(:where, query), statement(:group, query)])
end
end

0 comments on commit c5db7a1

Please sign in to comment.