Bake the single result expectation right into filter(key:) methods

This better hides this flag inside SQLSelectQuery, and avoids explicit support from FetchableRecord and TableRecord
This commit is contained in:
Gwendal Roué committed 2019-04-16 08:47:50 +02:00
1 parent 46791c8f74
commit 4716f91d8b
5 files changed
+48 -28

No files matched your search

+5 -5
View File
@@ -4,7 +4,7 @@
struct SQLSelectQuery {
var relation: SQLRelation
var isDistinct: Bool
var expectsSingleRecord: Bool
var expectsSingleResult: Bool
var groupPromise: DatabasePromise<[SQLExpression]>?
var havingExpression: SQLExpression?
var limit: SQLLimit?
@@ -12,14 +12,14 @@ struct SQLSelectQuery {
init(
relation: SQLRelation,
isDistinct: Bool = false,
expectsSingleRecord: Bool = false,
expectsSingleResult: Bool = false,
groupPromise: DatabasePromise<[SQLExpression]>? = nil,
havingExpression: SQLExpression? = nil,
limit: SQLLimit? = nil)
{
self.relation = relation
self.isDistinct = isDistinct
self.expectsSingleRecord = expectsSingleRecord
self.expectsSingleResult = expectsSingleResult
self.groupPromise = groupPromise
self.havingExpression = havingExpression
self.limit = limit
@@ -41,9 +41,9 @@ extension SQLSelectQuery: SelectionRequest, FilteredRequest, OrderedRequest {
return query
}
func expectingSingleRecord() -> SQLSelectQuery {
func expectingSingleResult() -> SQLSelectQuery {
var query = self
query.expectsSingleRecord = true
query.expectsSingleResult = true
return query
}