/// Possible relations between items in a group
public enum QueryGroupRelation {
    case and, or
}

extension QueryBuilder {
    public typealias GroupClosure = (QueryBuilder<Model>) throws -> ()

    /// Create a query group.
    @discardableResult
    public func group(
        _ relation: QueryGroupRelation,
        closure: @escaping GroupClosure
    ) rethrows -> Self {
        let sub = copy()
        try closure(sub)
        let filter = QueryFilter(
            entity: Model.entity,
            method: .group(.or, sub.query.filters)
        )
        return addFilter(filter)
    }
}

/// Possible relations between items in a group
public enum QueryGroupRelation {
    case and, or
}

extension QueryBuilder {
    public typealias GroupClosure = (QueryBuilder<Model>) throws -> ()

    /// Create a query group.
    @discardableResult
    public func group(
        _ relation: QueryGroupRelation,
        closure: @escaping GroupClosure
    ) rethrows -> Self {
        let sub = copy()
        try closure(sub)
        let filter = QueryFilter(
            entity: Model.entity,
            method: .group(relation, sub.query.filters)
        )
        return addFilter(filter)
    }
}

Fix grouping several filters with `AND` instead of `OR`
Fix grouping several filters with `AND` instead of `OR`

This bug can have a severe impact — imagine a query like `userID = 123 AND string LIKE '%foo%'` returning *every user's data* instead of just the current users! I think there should really be tests to spot issues like this.