mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Rename SQLString to SQLLiteral
This commit is contained in:
1 parent
98e2d009c6
commit
f018c7f823
34 files changed
+532
-575
No files matched your search
@@ -108,7 +108,7 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
/// }
|
||||
public func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
// TODO: make arguments non optional
|
||||
return select(SQLString(sql: sql, arguments: arguments ?? .init()), as: type)
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments ?? .init()), as: type)
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*, and fetches values of
|
||||
@@ -119,7 +119,7 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
/// let request = Player.
|
||||
/// .filter(primaryKey: 42)
|
||||
/// .select(
|
||||
/// SQLString(
|
||||
/// SQLLiteral(
|
||||
/// sql: "IFNULL(name, ?)",
|
||||
/// arguments: ["Anonymous"]),
|
||||
/// as: String.self)
|
||||
@@ -134,12 +134,12 @@ extension QueryInterfaceRequest : DerivableRequest, AggregatingRequest {
|
||||
/// let request = Player.
|
||||
/// .filter(primaryKey: 42)
|
||||
/// .select(
|
||||
/// SQLString("IFNULL(name, \("Anonymous"))"),
|
||||
/// SQLLiteral("IFNULL(name, \("Anonymous"))"),
|
||||
/// as: String.self)
|
||||
/// let name: String? = try request.fetchOne(db)
|
||||
/// }
|
||||
public func select<RowDecoder>(_ sqlString: SQLString, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return select(SQLSelectionLiteral(sqlString), as: type)
|
||||
public func select<RowDecoder>(_ sqlLiteral: SQLLiteral, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return select(SQLSelectionLiteral(sqlLiteral), as: type)
|
||||
}
|
||||
|
||||
/// Creates a request which appends *selection*.
|
||||
@@ -374,15 +374,15 @@ extension TableRecord {
|
||||
/// 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(SQLString(sql: sql, arguments: arguments ?? .init()))
|
||||
return select(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*.
|
||||
///
|
||||
/// // SELECT id, email FROM player
|
||||
/// let request = Player.select(SQLString("id, email"))
|
||||
public static func select(_ sqlString: SQLString) -> QueryInterfaceRequest<Self> {
|
||||
return all().select(sqlString)
|
||||
/// let request = Player.select(SQLLiteral("id, email"))
|
||||
public static func select(_ sqlLiteral: SQLLiteral) -> QueryInterfaceRequest<Self> {
|
||||
return all().select(sqlLiteral)
|
||||
}
|
||||
|
||||
/// Creates a request which selects *selection*, and fetches values of
|
||||
@@ -419,7 +419,7 @@ extension TableRecord {
|
||||
/// }
|
||||
public static func select<RowDecoder>(sql: String, arguments: StatementArguments? = nil, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
// TODO: make arguments non optional
|
||||
return all().select(SQLString(sql: sql, arguments: arguments ?? .init()), as: type)
|
||||
return all().select(SQLLiteral(sql: sql, arguments: arguments ?? .init()), as: type)
|
||||
}
|
||||
|
||||
/// Creates a request which selects *sql*, and fetches values of
|
||||
@@ -427,11 +427,11 @@ extension TableRecord {
|
||||
///
|
||||
/// try dbQueue.read { db in
|
||||
/// // SELECT max(score) FROM player
|
||||
/// let request = Player.select(SQLString("max(score)"), as: Int.self)
|
||||
/// let request = Player.select(SQLLiteral("max(score)"), as: Int.self)
|
||||
/// let maxScore: Int? = try request.fetchOne(db)
|
||||
/// }
|
||||
public static func select<RowDecoder>(_ sqlString: SQLString, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return all().select(sqlString, as: type)
|
||||
public static func select<RowDecoder>(_ sqlLiteral: SQLLiteral, as type: RowDecoder.Type) -> QueryInterfaceRequest<RowDecoder> {
|
||||
return all().select(sqlLiteral, as: type)
|
||||
}
|
||||
|
||||
/// Creates a request with the provided *predicate*.
|
||||
@@ -510,25 +510,25 @@ extension TableRecord {
|
||||
/// 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(SQLString(sql: sql, arguments: arguments ?? .init()))
|
||||
return filter(SQLLiteral(sql: sql, arguments: arguments ?? .init()))
|
||||
}
|
||||
|
||||
/// Creates a request with the provided *predicate*.
|
||||
///
|
||||
/// // SELECT * FROM player WHERE email = 'arthur@example.com'
|
||||
/// let request = Player.filter(SQLString(sql: "email = ?", arguments: ["arthur@example.com"]))
|
||||
/// let request = Player.filter(SQLLiteral(sql: "email = ?", arguments: ["arthur@example.com"]))
|
||||
///
|
||||
/// With Swift 5, you can safely embed raw values in your SQL queries,
|
||||
/// without any risk of syntax errors or SQL injection:
|
||||
///
|
||||
/// let request = Player.filter(SQLString("email = \("arthur@example.com")))
|
||||
/// let request = Player.filter(SQLLiteral("email = \("arthur@example.com")))
|
||||
///
|
||||
/// 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(_ sqlString: SQLString) -> QueryInterfaceRequest<Self> {
|
||||
public static func filter(_ sqlLiteral: SQLLiteral) -> QueryInterfaceRequest<Self> {
|
||||
// NOT TESTED
|
||||
return all().filter(sqlString)
|
||||
return all().filter(sqlLiteral)
|
||||
}
|
||||
|
||||
/// Creates a request sorted according to the
|
||||
|
||||
Reference in new issue
Block a user