Skip to content

Commit e772e29

Browse files
Make aggregate check input columns.
1 parent 4e3d2ae commit e772e29

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

QueryBuilder.Tests/AggregateTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
using SqlKata.Compilers;
22
using SqlKata.Tests.Infrastructure;
3+
using System;
34
using Xunit;
45

56
namespace SqlKata.Tests
67
{
78
public class AggregateTests : TestSupport
89
{
10+
[Fact]
11+
public void AsAggregateEmpty()
12+
{
13+
Assert.Throws<ArgumentException>(() => new Query("A").AsAggregate("aggregate", new string[] { }));
14+
}
15+
916
[Fact]
1017
public void Count()
1118
{

QueryBuilder/Query.Aggregate.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ public partial class Query
77
{
88
public Query AsAggregate(string type, string[] columns = null)
99
{
10+
if (columns.Count() == 0)
11+
{
12+
throw new System.ArgumentException("Cannot aggregate without columns");
13+
}
1014

1115
Method = "aggregate";
1216

0 commit comments

Comments
 (0)