mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Statement arguments are generally non optional
This commit is contained in:
1 parent
f018c7f823
commit
aa6f55d72f
17 files changed
+95
-130
No files matched your search
@@ -106,9 +106,8 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
/// let request = Player.all().select(sql: "max(score)", as: Int.self)
|
||||
/// let maxScore: Int? = try request.fetchOne(db)
|
||||
/// }
|
||||
public func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
// TODO: make arguments non optional
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments ?? .init()), as: type)
|
||||
public func select<RowDecoder>(sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments), as: type)
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*, and fetches values of
|
||||
@@ -372,9 +371,8 @@ extension TableRecord {
|
||||
///
|
||||
/// // SELECT id, email FROM player
|
||||
/// let request = Player.select(sql: "id, email")
|
||||
public static func select(sql: String, arguments: StatementArguments? = nil) -> QueryInterfaceRequest<Self> {
|
||||
// TODO: make arguments non optional
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public static func select(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*.
|
||||
@@ -417,9 +415,8 @@ extension TableRecord {
|
||||
/// let request = Player.select(sql: "max(score)", as: Int.self)
|
||||
/// let maxScore: Int? = try request.fetchOne(db)
|
||||
/// }
|
||||
public static func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
// TODO: make arguments non optional
|
||||
return all().select(SQLLiteral(sql: sql, arguments: arguments ?? .init()), as: type)
|
||||
public static func select<RowDecoder>(sql: String, arguments: StatementArguments = StatementArguments(), as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return all().select(SQLLiteral(sql: sql, arguments: arguments), as: type)
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*, and fetches values of
|
||||
@@ -508,9 +505,8 @@ extension TableRecord {
|
||||
/// The selection defaults to all columns. This default can be changed for
|
||||
/// all requests by the `TableRecord.databaseSelection` property, or
|
||||
/// for individual requests with the `TableRecord.select` method.
|
||||
public static func filter(sql: String, arguments: StatementArguments? = nil) -> QueryInterfaceRequest<Self> {
|
||||
// TODO: make arguments non optional
|
||||
return filter(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public static func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return filter(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request with the provided *predicate*.
|
||||
@@ -580,7 +576,7 @@ extension TableRecord {
|
||||
/// The selection defaults to all columns. This default can be changed for
|
||||
/// all requests by the `TableRecord.databaseSelection` property, or
|
||||
/// for individual requests with the `TableRecord.select` method.
|
||||
public static func order(sql: String, arguments: StatementArguments? = nil) -> QueryInterfaceRequest<Self> {
|
||||
public static func order(sql: String, arguments: StatementArguments = StatementArguments()) -> QueryInterfaceRequest<Self> {
|
||||
return all().order(sql: sql, arguments: arguments)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,9 +51,8 @@ extension SelectionRequest {
|
||||
/// request
|
||||
/// .select(sql: "id")
|
||||
/// .select(sql: "email")
|
||||
public func select(sql: String, arguments: StatementArguments? = nil) -> Self {
|
||||
// TODO: make arguments non optional
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public func select(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*.
|
||||
@@ -122,9 +121,8 @@ extension FilteredRequest {
|
||||
/// // SELECT * FROM player WHERE email = 'arthur@example.com'
|
||||
/// var request = Player.all()
|
||||
/// request = request.filter(sql: "email = ?", arguments: ["arthur@example.com"])
|
||||
public func filter(sql: String, arguments: StatementArguments? = nil) -> Self {
|
||||
// TODO: make arguments non optional
|
||||
return filter(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public func filter(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return filter(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request with the provided *predicate* added to the
|
||||
@@ -322,9 +320,8 @@ extension AggregatingRequest {
|
||||
}
|
||||
|
||||
/// Creates a request with a new grouping.
|
||||
public func group(sql: String, arguments: StatementArguments? = nil) -> Self {
|
||||
// TODO: make arguments non optional
|
||||
return group(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public func group(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return group(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request with a new grouping.
|
||||
@@ -345,9 +342,8 @@ extension AggregatingRequest {
|
||||
|
||||
/// Creates a request with the provided *sql* added to the
|
||||
/// eventual set of already applied predicates.
|
||||
public func having(sql: String, arguments: StatementArguments? = nil) -> Self {
|
||||
// TODO: make arguments non optional
|
||||
return having(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public func having(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return having(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request with the provided *sql* added to the
|
||||
@@ -443,9 +439,8 @@ extension OrderedRequest {
|
||||
/// request
|
||||
/// .order(sql: "email")
|
||||
/// .order(sql: "name")
|
||||
public func order(sql: String, arguments: StatementArguments? = nil) -> Self {
|
||||
// TODO: make arguments non optional
|
||||
return order(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
public func order(sql: String, arguments: StatementArguments = StatementArguments()) -> Self {
|
||||
return order(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// Creates a request with the provided *sql* used for sorting.
|
||||
|
||||
@@ -49,10 +49,9 @@ public struct SQLExpressionLiteral : SQLExpression {
|
||||
/// SQLExpressionLiteral("1 + 2")
|
||||
/// SQLExpressionLiteral("? + ?", arguments: [1, 2])
|
||||
/// SQLExpressionLiteral(":one + :two", arguments: ["one": 1, "two": 2])
|
||||
public init(_ sql: String, arguments: StatementArguments? = nil) {
|
||||
// TODO: make arguments non optional
|
||||
public init(_ sql: String, arguments: StatementArguments = StatementArguments()) {
|
||||
// TODO: force sql parameter name: fetchCursor(db, sql:...)
|
||||
self.init(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
self.init(SQLLiteral(sql: sql, arguments: arguments))
|
||||
}
|
||||
|
||||
/// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features)
|
||||
|
||||
Reference in new issue
Block a user