Skip to content

Commit ac97489

Browse files
committed
Support comparable aggregations against base types
Looks like we were limited, previously, by the specific expression types. Fixes stephencelis#277. Signed-off-by: Stephen Celis <stephen@stephencelis.com>
1 parent fd7fba3 commit ac97489

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Source/Typed/AggregateFunctions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.Wr
8484

8585
}
8686

87-
extension ExpressionType where UnderlyingType : protocol<Value, Comparable> {
87+
extension ExpressionType where UnderlyingType : Value, UnderlyingType.Datatype : Comparable {
8888

8989
/// Builds a copy of the expression wrapped with the `max` aggregate
9090
/// function.
@@ -114,7 +114,7 @@ extension ExpressionType where UnderlyingType : protocol<Value, Comparable> {
114114

115115
}
116116

117-
extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.WrappedType : protocol<Value, Comparable> {
117+
extension ExpressionType where UnderlyingType : _OptionalType, UnderlyingType.WrappedType : Value, UnderlyingType.WrappedType.Datatype : Comparable {
118118

119119
/// Builds a copy of the expression wrapped with the `max` aggregate
120120
/// function.

Tests/AggregateFunctionsTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class AggregateFunctionsTests : XCTestCase {
2525
AssertSQL("max(\"doubleOptional\")", doubleOptional.max)
2626
AssertSQL("max(\"string\")", string.max)
2727
AssertSQL("max(\"stringOptional\")", stringOptional.max)
28+
AssertSQL("max(\"date\")", date.max)
29+
AssertSQL("max(\"dateOptional\")", dateOptional.max)
2830
}
2931

3032
func test_min_wrapsComparableExpressionsWithMinFunction() {
@@ -34,6 +36,8 @@ class AggregateFunctionsTests : XCTestCase {
3436
AssertSQL("min(\"doubleOptional\")", doubleOptional.min)
3537
AssertSQL("min(\"string\")", string.min)
3638
AssertSQL("min(\"stringOptional\")", stringOptional.min)
39+
AssertSQL("min(\"date\")", date.min)
40+
AssertSQL("min(\"dateOptional\")", dateOptional.min)
3741
}
3842

3943
func test_average_wrapsNumericExpressionsWithAvgFunction() {

0 commit comments

Comments
 (0)