mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-27 04:14:21 +00:00
83 lines
2.7 KiB
Swift
83 lines
2.7 KiB
Swift
//
|
|
// AssociationAggregate.swift
|
|
// GRDB
|
|
//
|
|
// Created by Gwendal Roué on 30/09/2018.
|
|
// Copyright © 2018 Gwendal Roué. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
/// TODO
|
|
public struct AssociationAggregate<RowDecoder> {
|
|
let aggregatedRequest: (QueryInterfaceRequest<RowDecoder>, TableAlias) -> QueryInterfaceRequest<RowDecoder>
|
|
let expression: SQLExpression
|
|
var alias: String?
|
|
|
|
init(
|
|
expression: SQLExpression,
|
|
aggregatedRequest: @escaping (QueryInterfaceRequest<RowDecoder>, TableAlias) -> QueryInterfaceRequest<RowDecoder>)
|
|
{
|
|
self.aggregatedRequest = aggregatedRequest
|
|
self.expression = expression
|
|
}
|
|
}
|
|
|
|
extension AssociationAggregate {
|
|
/// TODO
|
|
public func aliased(_ name: String) -> AssociationAggregate<RowDecoder> {
|
|
var aggregate = self
|
|
aggregate.alias = name
|
|
return aggregate
|
|
}
|
|
}
|
|
|
|
/// TODO
|
|
public prefix func ! <RowDecoder>(aggregate: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: !aggregate.expression,
|
|
aggregatedRequest: aggregate.aggregatedRequest)
|
|
}
|
|
|
|
/// TODO
|
|
public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible?) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: lhs.expression == rhs,
|
|
aggregatedRequest: lhs.aggregatedRequest)
|
|
}
|
|
|
|
/// TODO
|
|
public func == <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: lhs.expression == rhs,
|
|
aggregatedRequest: lhs.aggregatedRequest)
|
|
}
|
|
|
|
/// TODO
|
|
public func == <RowDecoder>(lhs: SQLExpressible?, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: lhs == rhs.expression,
|
|
aggregatedRequest: rhs.aggregatedRequest)
|
|
}
|
|
|
|
/// TODO
|
|
public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: SQLExpressible?) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: lhs.expression != rhs,
|
|
aggregatedRequest: lhs.aggregatedRequest)
|
|
}
|
|
|
|
/// TODO
|
|
public func != <RowDecoder>(lhs: SQLExpressible?, rhs: AssociationAggregate<RowDecoder>) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: lhs != rhs.expression,
|
|
aggregatedRequest: rhs.aggregatedRequest)
|
|
}
|
|
|
|
/// TODO
|
|
public func != <RowDecoder>(lhs: AssociationAggregate<RowDecoder>, rhs: Bool) -> AssociationAggregate<RowDecoder> {
|
|
return AssociationAggregate(
|
|
expression: lhs.expression != rhs,
|
|
aggregatedRequest: lhs.aggregatedRequest)
|
|
}
|