 
 // MARK: - LENGTH(...)
 
-/// Returns an aggregate that evaluates the `LENGTH` SQL function on the
-/// input aggregate.
+/// The `LENGTH` SQL function.
 public func length<RowDecoder>(_ aggregate: AssociationAggregate<RowDecoder>)
 -> AssociationAggregate<RowDecoder>
 {

// MARK: - IFNULL(...)

extension AssociationAggregate {
    /// Returns an aggregate that evaluates the `IFNULL` SQL function.
    ///
    ///     Team.annotated(with: Team.players.min(Column("score")) ?? 0)
    public static func ?? (lhs: Self, rhs: some SQLExpressible) -> Self {
        lhs
            .map { $0 ?? rhs }

// MARK: - Comparison Operators (<, >, <=, >=)

extension AssociationAggregate {
    /// The `<=` SQL operator.
    public static func <= (lhs: Self, rhs: Self) -> Self {
        combine(lhs, rhs, with: <=)
    }
    
    /// The `<=` SQL operator.
    public static func <= (lhs: Self, rhs: some SQLExpressible) -> Self {
        lhs.map { $0 <= rhs }
    }
    
    /// The `<=` SQL operator.
    public static func <= (lhs: some SQLExpressible, rhs: Self) -> Self {
        rhs.map { lhs <= $0 }
    }
    
    /// The `<` SQL operator.
    public static func < (lhs: Self, rhs: Self) -> Self {
        combine(lhs, rhs, with: <)
    }
    
    /// The `<` SQL operator.
    public static func < (lhs: Self, rhs: some SQLExpressible) -> Self {
        lhs.map { $0 < rhs }
    }
    
    /// The `<` SQL operator.
    public static func < (lhs: some SQLExpressible, rhs: Self) -> Self {
        rhs.map { lhs < $0 }
    }
    
    /// The `>` SQL operator.
    public static func > (lhs: Self, rhs: Self) -> Self {
        combine(lhs, rhs, with: >)
    }
    
    /// The `>` SQL operator.
    public static func > (lhs: Self, rhs: some SQLExpressible) -> Self {
        lhs.map { $0 > rhs }
    }
    
    /// The `>` SQL operator.
    public static func > (lhs: some SQLExpressible, rhs: Self) -> Self {
        rhs.map { lhs > $0 }
    }
    
    /// The `>=` SQL operator.
    public static func >= (lhs: Self, rhs: Self) -> Self {
        combine(lhs, rhs, with: >=)
    }
    
    /// The `>=` SQL operator.
    public static func >= (lhs: Self, rhs: some SQLExpressible) -> Self {
        lhs.map { $0 >= rhs }
    }
    
    /// The `>=` SQL operator.
    public static func >= (lhs: some SQLExpressible, rhs: Self) -> Self {
        rhs.map { lhs >= $0 }
    }
