mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Documentation
This commit is contained in:
1 parent
086e3e918e
commit
d13968b753
2 files changed
+27
-14
No files matched your search
@@ -1,12 +1,12 @@
|
||||
#if swift(>=5.0)
|
||||
/// :nodoc:
|
||||
public struct SQLInterpolation: StringInterpolationProtocol {
|
||||
var context = SQLGenerationContext.literalGenerationContext(withArguments: true)
|
||||
var sql: String
|
||||
var arguments: StatementArguments {
|
||||
get { return context.arguments! }
|
||||
set { context.arguments = newValue }
|
||||
}
|
||||
var context = SQLGenerationContext.literalGenerationContext(withArguments: true)
|
||||
|
||||
public init(literalCapacity: Int, interpolationCount: Int) {
|
||||
sql = ""
|
||||
|
||||
+26
-13
@@ -1,11 +1,36 @@
|
||||
/// A FetchRequest built from raw SQL.
|
||||
public struct SQLRequest<T> : FetchRequest {
|
||||
/// There are two statement caches: one "public" for statements generated by
|
||||
/// the user, and one "internal" for the statements generated by GRDB. Those
|
||||
/// are separated so that GRDB has no opportunity to inadvertently modify
|
||||
/// the arguments of user's cached statements.
|
||||
enum Cache {
|
||||
/// The public cache, for library user
|
||||
case `public`
|
||||
|
||||
/// The internal cache, for GRDB
|
||||
case `internal`
|
||||
}
|
||||
|
||||
public typealias RowDecoder = T
|
||||
|
||||
public var adapter: RowAdapter?
|
||||
/// The raw SQL query
|
||||
///
|
||||
/// let id = 42
|
||||
/// let request: SQLRequest<Player> = "SELECT * FROM player WHERE id = \(id)"
|
||||
/// request.sql // "SELECT * FROM player WHERE id = ?"
|
||||
public var sql: String { return sqlLiteral.sql }
|
||||
|
||||
/// The request argument
|
||||
///
|
||||
/// let id = 42
|
||||
/// let request: SQLRequest<Player> = "SELECT * FROM player WHERE id = \(id)"
|
||||
/// request.arguments // [42]
|
||||
public var arguments: StatementArguments { return sqlLiteral.arguments }
|
||||
|
||||
/// The request adapter
|
||||
public var adapter: RowAdapter?
|
||||
|
||||
private var sqlLiteral: SQLLiteral
|
||||
private let cache: Cache?
|
||||
|
||||
@@ -116,18 +141,6 @@ public struct SQLRequest<T> : FetchRequest {
|
||||
try statement.setArgumentsWithValidation(sqlLiteral.arguments)
|
||||
return (statement, adapter)
|
||||
}
|
||||
|
||||
/// There are two statement caches: one for statements generated by the
|
||||
/// user, and one for the statements generated by GRDB. Those are separated
|
||||
/// so that GRDB has no opportunity to inadvertently modify the arguments of
|
||||
/// user's cached statements.
|
||||
enum Cache {
|
||||
/// The public cache, for library user
|
||||
case `public`
|
||||
|
||||
/// The internal cache, for grdb
|
||||
case `internal`
|
||||
}
|
||||
}
|
||||
|
||||
#if swift(>=5.0)
|
||||
|
||||
Reference in new issue
Block a user