-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from OctopusDeploy/andrew-w/group-by-trial
Adding GroupBy Support
- Loading branch information
Showing
8 changed files
with
179 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Nevermore.Querying.AST | ||
{ | ||
public class GroupBy | ||
{ | ||
readonly IReadOnlyList<GroupByField> fields; | ||
|
||
public GroupBy(IReadOnlyList<GroupByField> fields) | ||
{ | ||
if (fields.Count < 1) throw new ArgumentException("Fields must have at least one value"); | ||
this.fields = fields; | ||
} | ||
|
||
public string GenerateSql() | ||
{ | ||
return @$" | ||
GROUP BY {string.Join(@", ", fields.Select(f => f.GenerateSql()))}"; | ||
} | ||
|
||
public override string ToString() => GenerateSql(); | ||
} | ||
|
||
public class GroupByField | ||
{ | ||
readonly IColumn column; | ||
|
||
public GroupByField(IColumn column) | ||
{ | ||
this.column = column; | ||
} | ||
|
||
public string GenerateSql() => column.GenerateSql(); | ||
|
||
public override string ToString() => GenerateSql(); | ||
} | ||
} |
Oops, something went wrong.