From 2289ed9d95b16f8e852c8ba2cd0238b98f8d3fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 21 Jan 2018 16:57:43 +0100 Subject: [PATCH] Cleanup Jazzy documentation from most redundant definitions and experimental APIs --- GRDB/Core/Cursor.swift | 6 +++ GRDB/Core/Database.swift | 6 +++ GRDB/Core/DatabaseCollation.swift | 2 + GRDB/Core/DatabaseError.swift | 22 +++++++--- GRDB/Core/DatabaseFunction.swift | 2 + GRDB/Core/DatabaseQueue.swift | 16 ++++++-- GRDB/Core/DatabaseReader.swift | 7 ++++ GRDB/Core/DatabaseRegion.swift | 10 +++-- GRDB/Core/DatabaseValue.swift | 22 +++++++--- GRDB/Core/DatabaseValueConvertible.swift | 3 ++ GRDB/Core/DatabaseWriter.swift | 10 +++++ GRDB/Core/Request.swift | 16 +++++++- GRDB/Core/Row.swift | 41 +++++++++++++------ GRDB/Core/RowAdapter.swift | 21 ++++++++++ GRDB/Core/Statement.swift | 29 +++++++++---- GRDB/Core/StatementColumnConvertible.swift | 2 + GRDB/Core/TransactionObserver.swift | 1 + GRDB/FTS/FTS4.swift | 1 + GRDB/Migration/DatabaseMigrator.swift | 2 + GRDB/QueryInterface/Column.swift | 2 + .../QueryInterfaceRequest.swift | 6 +++ .../QueryInterfaceSelectQueryDefinition.swift | 2 +- .../SQLCollatedExpression.swift | 4 ++ GRDB/QueryInterface/SQLCollection.swift | 2 + GRDB/QueryInterface/SQLExpressible.swift | 14 +++++++ .../SQLExpression+QueryInterface.swift | 26 ++++++++++++ GRDB/QueryInterface/SQLExpression.swift | 9 ++++ GRDB/QueryInterface/SQLOrdering.swift | 2 + .../SQLSelectable+QueryInterface.swift | 6 +++ GRDB/QueryInterface/SQLSelectable.swift | 4 ++ .../QueryInterface/Support/SQLOperators.swift | 2 +- GRDB/Record/Persistable.swift | 8 +++- GRDB/Record/RecordBox.swift | 12 ++++++ GRDB/Record/RowConvertible.swift | 1 + GRDB/Utils/Utils.swift | 8 ++++ 35 files changed, 283 insertions(+), 44 deletions(-) diff --git a/GRDB/Core/Cursor.swift b/GRDB/Core/Cursor.swift index 525b9c3e1..8d59f977e 100644 --- a/GRDB/Core/Cursor.swift +++ b/GRDB/Core/Cursor.swift @@ -87,6 +87,7 @@ public class AnyCursor : Cursor { /// Advances to the next element and returns it, or nil if no next /// element exists. + /// :nodoc: public func next() throws -> Element? { return try element() } @@ -231,6 +232,7 @@ public final class EnumeratedCursor : Cursor { /// Advances to the next element and returns it, or nil if no next /// element exists. + /// :nodoc: public func next() throws -> (Int, Base.Element)? { guard let element = try base.next() else { return nil } defer { index += 1 } @@ -251,6 +253,7 @@ public final class FilterCursor : Cursor { /// Advances to the next element and returns it, or nil if no next /// element exists. + /// :nodoc: public func next() throws -> Base.Element? { while let element = try base.next() { if try isIncluded(element) { @@ -275,6 +278,7 @@ public final class FlattenCursor : Cursor where Base.Element: Curs /// Advances to the next element and returns it, or nil if no next /// element exists. + /// :nodoc: public func next() throws -> Base.Element.Element? { while true { if let element = try inner?.next() { @@ -303,6 +307,7 @@ public final class MapCursor : Cursor { /// Advances to the next element and returns it, or nil if no next /// element exists. + /// :nodoc: public func next() throws -> Element? { guard let element = try base.next() else { return nil } return try transform(element) @@ -327,6 +332,7 @@ public final class IteratorCursor : Cursor { /// Advances to the next element and returns it, or nil if no next /// element exists. + /// :nodoc: public func next() -> Base.Element? { return base.next() } diff --git a/GRDB/Core/Database.swift b/GRDB/Core/Database.swift index f9d8b1c7d..cc82f0d96 100644 --- a/GRDB/Core/Database.swift +++ b/GRDB/Core/Database.swift @@ -817,8 +817,10 @@ extension Database { /// /// See https://www.sqlite.org/datatype3.html#collation public struct CollationName : RawRepresentable, Hashable { + /// :nodoc: public let rawValue: String + /// :nodoc: public init(rawValue: String) { self.rawValue = rawValue } @@ -828,6 +830,7 @@ extension Database { } /// The hash value + /// :nodoc: public var hashValue: Int { return rawValue.hashValue } @@ -851,8 +854,10 @@ extension Database { /// /// See https://www.sqlite.org/datatype3.html public struct ColumnType : RawRepresentable, Hashable { + /// :nodoc: public let rawValue: String + /// :nodoc: public init(rawValue: String) { self.rawValue = rawValue } @@ -862,6 +867,7 @@ extension Database { } /// The hash value + /// :nodoc: public var hashValue: Int { return rawValue.hashValue } diff --git a/GRDB/Core/DatabaseCollation.swift b/GRDB/Core/DatabaseCollation.swift index 426c86aff..41c6520af 100644 --- a/GRDB/Core/DatabaseCollation.swift +++ b/GRDB/Core/DatabaseCollation.swift @@ -33,6 +33,7 @@ public final class DatabaseCollation { } extension DatabaseCollation : Hashable { + /// :nodoc: public var hashValue: Int { // Collation equality is based on the sqlite3_strnicmp SQLite function. // (see https://www.sqlite.org/c3ref/create_collation.html). Computing @@ -44,6 +45,7 @@ extension DatabaseCollation : Hashable { } /// Two collations are equal if they share the same name (case insensitive) + /// :nodoc: public static func == (lhs: DatabaseCollation, rhs: DatabaseCollation) -> Bool { // See https://www.sqlite.org/c3ref/create_collation.html return sqlite3_stricmp(lhs.name, lhs.name) == 0 diff --git a/GRDB/Core/DatabaseError.swift b/GRDB/Core/DatabaseError.swift index 90d31c490..6833c383f 100644 --- a/GRDB/Core/DatabaseError.swift +++ b/GRDB/Core/DatabaseError.swift @@ -5,7 +5,7 @@ import Foundation import SQLite3 #endif -public struct ResultCode : RawRepresentable { +public struct ResultCode : RawRepresentable, Equatable, CustomStringConvertible { public let rawValue: Int32 public init(rawValue: Int32) { @@ -139,13 +139,17 @@ public struct ResultCode : RawRepresentable { public static let SQLITE_OK_LOAD_PERMANENTLY = ResultCode(rawValue: (SQLITE_OK.rawValue | (1<<8))) } -extension ResultCode : Equatable { +// Equatable +extension ResultCode { + /// :nodoc: public static func == (_ lhs: ResultCode, _ rhs: ResultCode) -> Bool { return lhs.rawValue == rhs.rawValue } } -extension ResultCode : CustomStringConvertible { +// CustomStringConvertible +extension ResultCode { + /// :nodoc: public var description: String { // sqlite3_errstr was added in SQLite 3.7.15 http://www.sqlite.org/changes.html#version_3_7_15 // It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS) @@ -162,7 +166,7 @@ extension ResultCode : CustomStringConvertible { } /// DatabaseError wraps an SQLite error. -public struct DatabaseError : Error { +public struct DatabaseError : Error, CustomStringConvertible, CustomNSError { /// The SQLite error code (see /// https://www.sqlite.org/rescode.html#primary_result_code_list). @@ -223,7 +227,9 @@ public struct DatabaseError : Error { let arguments: StatementArguments? } -extension DatabaseError: CustomStringConvertible { +// CustomStringConvertible +extension DatabaseError { + /// :nodoc: public var description: String { var description = "SQLite error \(resultCode.rawValue)" if let sql = sql { @@ -239,19 +245,23 @@ extension DatabaseError: CustomStringConvertible { } } -extension DatabaseError : CustomNSError { +// CustomNSError +extension DatabaseError { /// NSError bridging: the domain of the error. + /// :nodoc: public static var errorDomain: String { return "GRDB.DatabaseError" } /// NSError bridging: the error code within the given domain. + /// :nodoc: public var errorCode: Int { return Int(extendedResultCode.rawValue) } /// NSError bridging: the user-info dictionary. + /// :nodoc: public var errorUserInfo: [String : Any] { return [NSLocalizedDescriptionKey: description] } diff --git a/GRDB/Core/DatabaseFunction.swift b/GRDB/Core/DatabaseFunction.swift index cecc315f4..8de8d1ed4 100644 --- a/GRDB/Core/DatabaseFunction.swift +++ b/GRDB/Core/DatabaseFunction.swift @@ -311,11 +311,13 @@ public final class DatabaseFunction { extension DatabaseFunction : Hashable { /// The hash value + /// :nodoc: public var hashValue: Int { return name.hashValue ^ nArg.hashValue } /// Two functions are equal if they share the same name and arity. + /// :nodoc: public static func == (lhs: DatabaseFunction, rhs: DatabaseFunction) -> Bool { return lhs.name == rhs.name && lhs.nArg == rhs.nArg } diff --git a/GRDB/Core/DatabaseQueue.swift b/GRDB/Core/DatabaseQueue.swift index 7ac697336..6d69228f3 100644 --- a/GRDB/Core/DatabaseQueue.swift +++ b/GRDB/Core/DatabaseQueue.swift @@ -188,8 +188,8 @@ extension DatabaseQueue { extension DatabaseQueue : DatabaseReader { - // MARK: - DatabaseReader Protocol Adoption - + // MARK: - Reading from Database + /// Synchronously executes a read-only block in a protected dispatch queue, /// and returns its result. /// @@ -220,6 +220,8 @@ extension DatabaseQueue : DatabaseReader { } /// Alias for `inDatabase`. See `DatabaseReader.unsafeRead`. + /// + /// :nodoc: public func unsafeRead(_ block: (Database) throws -> T) rethrows -> T { return try inDatabase(block) } @@ -233,6 +235,8 @@ extension DatabaseQueue : DatabaseReader { /// /// This method is reentrant. It should be avoided because it fosters /// dangerous concurrency practices. + /// + /// :nodoc: public func unsafeReentrantRead(_ block: (Database) throws -> T) throws -> T { return try serializedDatabase.reentrantSync(block) } @@ -282,10 +286,10 @@ extension DatabaseQueue : DatabaseReader { } extension DatabaseQueue : DatabaseWriter { - - // MARK: - DatabaseWriter Protocol Adoption /// Alias for `inDatabase`. See `DatabaseWriter.write`. + /// + /// :nodoc: public func write(_ block: (Database) throws -> T) rethrows -> T { return try inDatabase(block) } @@ -300,6 +304,8 @@ extension DatabaseQueue : DatabaseWriter { /// outside of a transaction. You'll get a fatal error otherwise. /// /// See `DatabaseWriter.readFromCurrentState`. + /// + /// :nodoc: public func readFromCurrentState(_ block: @escaping (Database) -> Void) { // Check that we're on the correct queue... serializedDatabase.execute { db in @@ -320,6 +326,8 @@ extension DatabaseQueue : DatabaseWriter { } } + // MARK: - Unsafe Database Access + /// Synchronously executes a block in a protected dispatch queue, and /// returns its result. /// diff --git a/GRDB/Core/DatabaseReader.swift b/GRDB/Core/DatabaseReader.swift index c632b426b..5a33d8f20 100644 --- a/GRDB/Core/DatabaseReader.swift +++ b/GRDB/Core/DatabaseReader.swift @@ -223,34 +223,41 @@ public final class AnyDatabaseReader : DatabaseReader { // MARK: - Reading from Database + /// :nodoc: public func read(_ block: (Database) throws -> T) throws -> T { return try base.read(block) } + /// :nodoc: public func unsafeRead(_ block: (Database) throws -> T) throws -> T { return try base.unsafeRead(block) } + /// :nodoc: public func unsafeReentrantRead(_ block: (Database) throws -> T) throws -> T { return try base.unsafeReentrantRead(block) } // MARK: - Functions + /// :nodoc: public func add(function: DatabaseFunction) { base.add(function: function) } + /// :nodoc: public func remove(function: DatabaseFunction) { base.remove(function: function) } // MARK: - Collations + /// :nodoc: public func add(collation: DatabaseCollation) { base.add(collation: collation) } + /// :nodoc: public func remove(collation: DatabaseCollation) { base.remove(collation: collation) } diff --git a/GRDB/Core/DatabaseRegion.swift b/GRDB/Core/DatabaseRegion.swift index 60d029950..52f67a6fb 100644 --- a/GRDB/Core/DatabaseRegion.swift +++ b/GRDB/Core/DatabaseRegion.swift @@ -39,7 +39,7 @@ /// // A query interface request that executes the same statement: /// let request = Player.filter(key: 1) /// try request.fetchedRegion(db) // "players(*)[1]" -public struct DatabaseRegion { +public struct DatabaseRegion: CustomStringConvertible, Equatable { private let tableRegions: [String: TableRegion]? private init(tableRegions: [String: TableRegion]?) { self.tableRegions = tableRegions @@ -192,7 +192,9 @@ extension DatabaseRegion { } } -extension DatabaseRegion: Equatable { +// Equatable +extension DatabaseRegion { + /// :nodoc: public static func == (lhs: DatabaseRegion, rhs: DatabaseRegion) -> Bool { switch (lhs.tableRegions, rhs.tableRegions) { case (nil, nil): @@ -215,7 +217,9 @@ extension DatabaseRegion: Equatable { } } -extension DatabaseRegion: CustomStringConvertible { +// CustomStringConvertible +extension DatabaseRegion { + /// :nodoc: public var description: String { guard let tableRegions = tableRegions else { return "full database" diff --git a/GRDB/Core/DatabaseValue.swift b/GRDB/Core/DatabaseValue.swift index 57b7aee3d..ca6303549 100644 --- a/GRDB/Core/DatabaseValue.swift +++ b/GRDB/Core/DatabaseValue.swift @@ -10,7 +10,7 @@ import Foundation /// DatabaseValue is the intermediate type between SQLite and your values. /// /// See https://www.sqlite.org/datatype3.html -public struct DatabaseValue { +public struct DatabaseValue: Hashable, CustomStringConvertible, DatabaseValueConvertible, SQLExpressible, SQLExpression { /// The SQLite storage public let storage: Storage @@ -146,9 +146,11 @@ public struct DatabaseValue { // MARK: - Hashable & Equatable -extension DatabaseValue : Hashable { +// Hashable +extension DatabaseValue { /// The hash value + /// :nodoc: public var hashValue: Int { switch storage { case .null: @@ -280,7 +282,8 @@ extension DatabaseValue { } } -extension DatabaseValue : DatabaseValueConvertible { +// DatabaseValueConvertible +extension DatabaseValue { /// Returns self public var databaseValue: DatabaseValue { return self @@ -292,15 +295,19 @@ extension DatabaseValue : DatabaseValueConvertible { } } -extension DatabaseValue : SQLExpressible { +// SQLExpressible +extension DatabaseValue { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// :nodoc: public var sqlExpression: SQLExpression { return self } } -extension DatabaseValue : SQLExpression { +// SQLExpression +extension DatabaseValue { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// :nodoc: public func expressionSQL(_ arguments: inout StatementArguments?) -> String { // fast path for NULL if isNull { @@ -318,6 +325,7 @@ extension DatabaseValue : SQLExpression { } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// :nodoc: public var negated: SQLExpression { switch storage { case .null: @@ -343,7 +351,9 @@ extension DatabaseValue : SQLExpression { } } -extension DatabaseValue : CustomStringConvertible { +// CustomStringConvertible +extension DatabaseValue { + /// :nodoc: public var description: String { switch storage { case .null: diff --git a/GRDB/Core/DatabaseValueConvertible.swift b/GRDB/Core/DatabaseValueConvertible.swift index eeed050b9..43cbc96f9 100644 --- a/GRDB/Core/DatabaseValueConvertible.swift +++ b/GRDB/Core/DatabaseValueConvertible.swift @@ -32,6 +32,7 @@ public protocol DatabaseValueConvertible : SQLExpressible { extension DatabaseValueConvertible { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// :nodoc: public var sqlExpression: SQLExpression { return databaseValue } @@ -60,6 +61,7 @@ public final class DatabaseValueCursor : Cursor statement.cursorReset(arguments: arguments) } + /// :nodoc: public func next() throws -> Value? { if done { return nil } switch sqlite3_step(sqliteStatement) { @@ -99,6 +101,7 @@ public final class NullableDatabaseValueCursor statement.cursorReset(arguments: arguments) } + /// :nodoc: public func next() throws -> Value?? { if done { return nil } switch sqlite3_step(sqliteStatement) { diff --git a/GRDB/Core/DatabaseWriter.swift b/GRDB/Core/DatabaseWriter.swift index 89456ede4..5c5c1b003 100644 --- a/GRDB/Core/DatabaseWriter.swift +++ b/GRDB/Core/DatabaseWriter.swift @@ -96,48 +96,58 @@ public final class AnyDatabaseWriter : DatabaseWriter { // MARK: - Reading from Database + /// :nodoc: public func read(_ block: (Database) throws -> T) throws -> T { return try base.read(block) } + /// :nodoc: public func unsafeRead(_ block: (Database) throws -> T) throws -> T { return try base.unsafeRead(block) } + /// :nodoc: public func unsafeReentrantRead(_ block: (Database) throws -> T) throws -> T { return try base.unsafeReentrantRead(block) } + /// :nodoc: public func readFromCurrentState(_ block: @escaping (Database) -> Void) throws { try base.readFromCurrentState(block) } // MARK: - Writing in Database + /// :nodoc: public func write(_ block: (Database) throws -> T) rethrows -> T { return try base.write(block) } + /// :nodoc: public func unsafeReentrantWrite(_ block: (Database) throws -> T) rethrows -> T { return try base.unsafeReentrantWrite(block) } // MARK: - Functions + /// :nodoc: public func add(function: DatabaseFunction) { base.add(function: function) } + /// :nodoc: public func remove(function: DatabaseFunction) { base.remove(function: function) } // MARK: - Collations + /// :nodoc: public func add(collation: DatabaseCollation) { base.add(collation: collation) } + /// :nodoc: public func remove(collation: DatabaseCollation) { base.remove(collation: collation) } diff --git a/GRDB/Core/Request.swift b/GRDB/Core/Request.swift index 866c84647..86650ea85 100644 --- a/GRDB/Core/Request.swift +++ b/GRDB/Core/Request.swift @@ -103,6 +103,7 @@ public struct AdaptedRequest : Request { self.adapter = adapter } + /// :nodoc: public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { let (statement, baseAdapter) = try base.prepare(db) if let baseAdapter = baseAdapter { @@ -112,10 +113,12 @@ public struct AdaptedRequest : Request { } } + /// :nodoc: public func fetchCount(_ db: Database) throws -> Int { return try base.fetchCount(db) } + /// :nodoc: public func fetchedRegion(_ db: Database) throws -> DatabaseRegion { return try base.fetchedRegion(db) } @@ -145,14 +148,17 @@ public struct AnyRequest : Request { base = PrepareRequest(base: prepare) } + /// :nodoc: public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { return try base.prepare(db) } + /// :nodoc: public func fetchCount(_ db: Database) throws -> Int { return try base.fetchCount(db) } + /// :nodoc: public func fetchedRegion(_ db: Database) throws -> DatabaseRegion { return try base.fetchedRegion(db) } @@ -205,7 +211,9 @@ public struct SQLRequest : Request { /// executed, and an eventual row adapter. /// /// - parameter db: A database connection. - public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { + /// + /// :nodoc: + public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { let statement: SelectStatement switch cache { case .none: @@ -272,14 +280,17 @@ public struct AdaptedTypedRequest : TypedRequest { self.base = AdaptedRequest(base, adapter) } + /// :nodoc: public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { return try base.prepare(db) } + /// :nodoc: public func fetchCount(_ db: Database) throws -> Int { return try base.fetchCount(db) } + /// :nodoc: public func fetchedRegion(_ db: Database) throws -> DatabaseRegion { return try base.fetchedRegion(db) } @@ -311,14 +322,17 @@ public struct AnyTypedRequest : TypedRequest { base = AnyRequest(prepare) } + /// :nodoc: public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { return try base.prepare(db) } + /// :nodoc: public func fetchCount(_ db: Database) throws -> Int { return try base.fetchCount(db) } + /// :nodoc: public func fetchedRegion(_ db: Database) throws -> DatabaseRegion { return try base.fetchedRegion(db) } diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index 68da9433a..411f45002 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -6,7 +6,7 @@ import Foundation #endif /// A database row. -public final class Row { +public final class Row : Equatable, Hashable, RandomAccessCollection, ExpressibleByDictionaryLiteral, CustomStringConvertible { let impl: RowImpl /// Unless we are producing a row array, we use a single row when iterating @@ -506,6 +506,7 @@ public final class RowCursor : Cursor { statement.cursorReset(arguments: arguments) } + /// :nodoc: public func next() throws -> Row? { if done { return nil } switch sqlite3_step(sqliteStatement) { @@ -725,7 +726,8 @@ extension Row { } } -extension Row : ExpressibleByDictionaryLiteral { +// ExpressibleByDictionaryLiteral +extension Row { /// Creates a row initialized with elements. Column order is preserved, and /// duplicated columns names are allowed. @@ -738,17 +740,20 @@ extension Row : ExpressibleByDictionaryLiteral { } } -extension Row : RandomAccessCollection { +// RandomAccessCollection +extension Row { // MARK: - Row as a Collection of (ColumnName, DatabaseValue) Pairs /// The index of the first (ColumnName, DatabaseValue) pair. + /// :nodoc: public var startIndex: RowIndex { return Index(0) } /// The "past-the-end" index, successor of the index of the last /// (ColumnName, DatabaseValue) pair. + /// :nodoc: public var endIndex: RowIndex { return Index(count) } @@ -763,11 +768,12 @@ extension Row : RandomAccessCollection { } } -/// Row adopts Equatable. -extension Row : Equatable { +// Equatable +extension Row { /// Returns true if and only if both rows have the same columns and values, /// in the same order. Columns are compared in a case-sensitive way. + /// :nodoc: public static func == (lhs: Row, rhs: Row) -> Bool { if lhs === rhs { return true @@ -804,17 +810,19 @@ extension Row : Equatable { } } -/// Row adopts Hashable. -extension Row : Hashable { +// Hashable +extension Row { /// The hash value + /// :nodoc: public var hashValue: Int { return columnNames.reduce(0) { (acc, column) in acc ^ column.hashValue } ^ databaseValues.reduce(0) { (acc, dbValue) in acc ^ dbValue.hashValue } } } -/// Row adopts CustomStringConvertible. -extension Row: CustomStringConvertible { +// CustomStringConvertible +extension Row { + /// :nodoc: public var description: String { return " Bool { return lhs.index == rhs.index } + /// :nodoc: public static func < (lhs: RowIndex, rhs: RowIndex) -> Bool { return lhs.index < rhs.index } } -// Support for Row: RandomAccessCollection -extension RowIndex: Strideable { +// Strideable: support for Row: RandomAccessCollection +extension RowIndex { + /// :nodoc: public func distance(to other: RowIndex) -> Int { return other.index - index } + /// :nodoc: public func advanced(by n: Int) -> RowIndex { return RowIndex(index + n) } diff --git a/GRDB/Core/RowAdapter.swift b/GRDB/Core/RowAdapter.swift index 16df6e363..af802b226 100644 --- a/GRDB/Core/RowAdapter.swift +++ b/GRDB/Core/RowAdapter.swift @@ -3,6 +3,8 @@ import Foundation /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// LayoutedColumnMapping is a type that supports the RowAdapter protocol. +/// +/// :nodoc: public struct LayoutedColumnMapping { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -56,6 +58,8 @@ public struct LayoutedColumnMapping { } /// LayoutedColumnMapping adopts LayoutedRowAdapter +/// +/// :nodoc: extension LayoutedColumnMapping : LayoutedRowAdapter { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -72,6 +76,7 @@ extension LayoutedColumnMapping : LayoutedRowAdapter { } } +/// :nodoc: extension LayoutedColumnMapping : RowLayout { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -91,6 +96,8 @@ extension LayoutedColumnMapping : RowLayout { /// /// GRBD ships with a ready-made type that adopts this protocol: /// LayoutedColumnMapping. +/// +/// :nodoc: public protocol LayoutedRowAdapter { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -108,6 +115,8 @@ public protocol LayoutedRowAdapter { /// /// RowLayout is a protocol that supports the RowAdapter protocol. It describes /// a layout of a base row. +/// +/// :nodoc: public protocol RowLayout { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -124,11 +133,15 @@ public protocol RowLayout { extension SelectStatement : RowLayout { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public var layoutColumns: [(Int, String)] { return Array(columnNames.enumerated()) } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func layoutIndex(ofColumn name: String) -> Int? { return index(ofColumn: name) } @@ -214,6 +227,8 @@ public struct ColumnMapping : RowAdapter { } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter { let layoutColumns = try mapping .map { (mappedColumn, baseColumn) -> (Int, String) in @@ -250,6 +265,8 @@ public struct SuffixRowAdapter : RowAdapter { } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter { return LayoutedColumnMapping(layoutColumns: layout.layoutColumns.suffix(from: index)) } @@ -279,6 +296,8 @@ public struct RangeRowAdapter : RowAdapter { } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter { return LayoutedColumnMapping(layoutColumns: layout.layoutColumns[range]) } @@ -329,6 +348,8 @@ public struct ScopeAdapter : RowAdapter { } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func layoutedAdapter(from layout: RowLayout) throws -> LayoutedRowAdapter { let layoutedAdapter = try mainAdapter.layoutedAdapter(from: layout) var layoutedScopes = layoutedAdapter.scopes diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index f2914d234..f29a1536f 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -291,10 +291,12 @@ extension AuthorizedStatement { /// let moreThanTwentyCount = try Int.fetchOne(statement, arguments: [20])! /// let moreThanThirtyCount = try Int.fetchOne(statement, arguments: [30])! /// } -public final class SelectStatement : Statement, AuthorizedStatement { +public final class SelectStatement : Statement { + /// :nodoc: @available(*, deprecated, renamed:"DatabaseRegion") public typealias SelectionInfo = DatabaseRegion + /// :nodoc: @available(*, deprecated, renamed:"fetchedRegion") public var selectionInfo: DatabaseRegion { return fetchedRegion } @@ -372,6 +374,9 @@ public final class SelectStatement : Statement, AuthorizedStatement { } } +// Hide AuthorizedStatement from Jazzy +extension SelectStatement: AuthorizedStatement { } + /// A cursor that iterates a database statement without producing any value. /// For example: /// @@ -391,6 +396,7 @@ public final class StatementCursor: Cursor { statement.cursorReset(arguments: arguments) } + /// :nodoc: public func next() throws -> Void? { if done { return nil } switch sqlite3_step(sqliteStatement) { @@ -419,7 +425,7 @@ public final class StatementCursor: Cursor { /// try statement.execute(arguments: ["Barbara"]) /// return .commit /// } -public final class UpdateStatement : Statement, AuthorizedStatement { +public final class UpdateStatement : Statement { enum TransactionEffect { case beginTransaction case commitTransaction @@ -510,6 +516,9 @@ public final class UpdateStatement : Statement, AuthorizedStatement { } } +// Hide AuthorizedStatement from Jazzy +extension UpdateStatement: AuthorizedStatement { } + // MARK: - StatementArguments @@ -584,7 +593,7 @@ public final class UpdateStatement : Statement, AuthorizedStatement { /// let row = try Row.fetchOne(db, sql, arguments: [1, 2, "bar"] + ["foo": "foo"])! /// print(row) /// // Prints -public struct StatementArguments { +public struct StatementArguments: CustomStringConvertible, Equatable, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral { var values: [DatabaseValue] = [] var namedValues: [String: DatabaseValue] = [:] @@ -870,7 +879,8 @@ public struct StatementArguments { } } -extension StatementArguments : ExpressibleByArrayLiteral { +// ExpressibleByArrayLiteral +extension StatementArguments { /// Returns a StatementArguments from an array literal: /// /// db.selectRows("SELECT ...", arguments: ["Arthur", 41]) @@ -879,7 +889,8 @@ extension StatementArguments : ExpressibleByArrayLiteral { } } -extension StatementArguments : ExpressibleByDictionaryLiteral { +// ExpressibleByDictionaryLiteral +extension StatementArguments { /// Returns a StatementArguments from a dictionary literal: /// /// db.selectRows("SELECT ...", arguments: ["name": "Arthur", "score": 41]) @@ -888,7 +899,9 @@ extension StatementArguments : ExpressibleByDictionaryLiteral { } } -extension StatementArguments : CustomStringConvertible { +// CustomStringConvertible +extension StatementArguments { + /// :nodoc: public var description: String { let valuesDescriptions = values.map { $0.description } let namedValuesDescriptions = namedValues.map { (key, value) -> String in @@ -898,7 +911,9 @@ extension StatementArguments : CustomStringConvertible { } } -extension StatementArguments : Equatable { +// Equatable +extension StatementArguments { + /// :nodoc: public static func == (lhs: StatementArguments, rhs: StatementArguments) -> Bool { if lhs.values != rhs.values { return false } if lhs.namedValues != rhs.namedValues { return false } diff --git a/GRDB/Core/StatementColumnConvertible.swift b/GRDB/Core/StatementColumnConvertible.swift index 418397ab9..2c6c38237 100644 --- a/GRDB/Core/StatementColumnConvertible.swift +++ b/GRDB/Core/StatementColumnConvertible.swift @@ -73,6 +73,7 @@ public final class ColumnCursor Value? { if done { return nil } switch sqlite3_step(sqliteStatement) { @@ -118,6 +119,7 @@ public final class NullableColumnCursor Value?? { if done { return nil } switch sqlite3_step(sqliteStatement) { diff --git a/GRDB/Core/TransactionObserver.swift b/GRDB/Core/TransactionObserver.swift index ef6256d1d..0d3f0bfe5 100644 --- a/GRDB/Core/TransactionObserver.swift +++ b/GRDB/Core/TransactionObserver.swift @@ -875,6 +875,7 @@ public enum DatabaseEventKind { } } + /// :nodoc: @available(*, deprecated, message: "Use DatabaseRegion.isModified(byEventsOfKind:) instead") public func impacts(_ region: DatabaseRegion) -> Bool { return region.isModified(byEventsOfKind: self) diff --git a/GRDB/FTS/FTS4.swift b/GRDB/FTS/FTS4.swift index ae3e1f9f1..7fea3dc75 100644 --- a/GRDB/FTS/FTS4.swift +++ b/GRDB/FTS/FTS4.swift @@ -269,6 +269,7 @@ public final class FTS4ColumnDefinition { /// See https://www.sqlite.org/fts3.html#the_notindexed_option /// /// - returns: Self so that you can further refine the column definition. + /// :nodoc: @discardableResult public func notIndexed() -> Self { // notindexed FTS4 option was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0 diff --git a/GRDB/Migration/DatabaseMigrator.swift b/GRDB/Migration/DatabaseMigrator.swift index 0d43334ee..b6de0e654 100644 --- a/GRDB/Migration/DatabaseMigrator.swift +++ b/GRDB/Migration/DatabaseMigrator.swift @@ -85,6 +85,8 @@ public struct DatabaseMigrator { /// - identifier: The migration identifier. /// - block: The migration block that performs SQL statements. /// - precondition: No migration with the same same as already been registered. + /// + /// :nodoc: public mutating func registerMigrationWithDeferredForeignKeyCheck(_ identifier: String, migrate: @escaping (Database) throws -> Void) { registerMigration(Migration(identifier: identifier, disabledForeignKeyChecks: true, migrate: migrate)) } diff --git a/GRDB/QueryInterface/Column.swift b/GRDB/QueryInterface/Column.swift index 9aa338943..98e60489e 100644 --- a/GRDB/QueryInterface/Column.swift +++ b/GRDB/QueryInterface/Column.swift @@ -17,6 +17,8 @@ public struct Column { extension Column : SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func expressionSQL(_ arguments: inout StatementArguments?) -> String { return name.quotedDatabaseIdentifier } diff --git a/GRDB/QueryInterface/QueryInterfaceRequest.swift b/GRDB/QueryInterface/QueryInterfaceRequest.swift index 5e58e3a30..8cd1c29fc 100644 --- a/GRDB/QueryInterface/QueryInterfaceRequest.swift +++ b/GRDB/QueryInterface/QueryInterfaceRequest.swift @@ -16,6 +16,8 @@ extension QueryInterfaceRequest : TypedRequest { /// executed, and an eventual row adapter. /// /// - parameter db: A database connection. + /// + /// :nodoc: public func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) { return try query.prepare(db) } @@ -23,11 +25,15 @@ extension QueryInterfaceRequest : TypedRequest { /// The number of rows fetched by the request. /// /// - parameter db: A database connection. + /// + /// :nodoc: public func fetchCount(_ db: Database) throws -> Int { return try query.fetchCount(db) } /// The database region that the request looks into. + /// + /// :nodoc: public func fetchedRegion(_ db: Database) throws -> DatabaseRegion { return try query.fetchedRegion(db) } diff --git a/GRDB/QueryInterface/QueryInterfaceSelectQueryDefinition.swift b/GRDB/QueryInterface/QueryInterfaceSelectQueryDefinition.swift index 75bc97477..a15c19729 100644 --- a/GRDB/QueryInterface/QueryInterfaceSelectQueryDefinition.swift +++ b/GRDB/QueryInterface/QueryInterfaceSelectQueryDefinition.swift @@ -182,7 +182,7 @@ extension QueryInterfaceSelectQueryDefinition : Request { } /// The database region that the request looks into. - public func fetchedRegion(_ db: Database) throws -> DatabaseRegion { + func fetchedRegion(_ db: Database) throws -> DatabaseRegion { let (statement, _) = try prepare(db) let region = statement.fetchedRegion diff --git a/GRDB/QueryInterface/SQLCollatedExpression.swift b/GRDB/QueryInterface/SQLCollatedExpression.swift index e8c9d345e..492f625cc 100644 --- a/GRDB/QueryInterface/SQLCollatedExpression.swift +++ b/GRDB/QueryInterface/SQLCollatedExpression.swift @@ -51,11 +51,15 @@ public struct SQLCollatedExpression { extension SQLCollatedExpression : SQLOrderingTerm { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public var reversed: SQLOrderingTerm { return desc } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func orderingTermSQL(_ arguments: inout StatementArguments?) -> String { return sqlExpression.orderingTermSQL(&arguments) } diff --git a/GRDB/QueryInterface/SQLCollection.swift b/GRDB/QueryInterface/SQLCollection.swift index 3b582790a..22923ae0e 100644 --- a/GRDB/QueryInterface/SQLCollection.swift +++ b/GRDB/QueryInterface/SQLCollection.swift @@ -3,6 +3,8 @@ /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// SQLCollection is the protocol for types that can be checked for inclusion. +/// +/// :nodoc: public protocol SQLCollection { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// diff --git a/GRDB/QueryInterface/SQLExpressible.swift b/GRDB/QueryInterface/SQLExpressible.swift index e4906d3ee..1ee8ec614 100644 --- a/GRDB/QueryInterface/SQLExpressible.swift +++ b/GRDB/QueryInterface/SQLExpressible.swift @@ -8,6 +8,8 @@ /// like Column. /// /// See https://github.com/groue/GRDB.swift/#the-query-interface +/// +/// :nodoc: public protocol SQLExpressible { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -27,6 +29,8 @@ public protocol SQLExpressible { /// and it adopts SQLSpecificExpressible. /// /// On the other side, Int adopts SQLExpressible (via DatabaseValueConvertible). +/// +/// :nodoc: public protocol SQLSpecificExpressible : SQLExpressible { // SQLExpressible can be adopted by Swift standard types, and user // types, through the DatabaseValueConvertible protocol which inherits @@ -53,11 +57,15 @@ public protocol SQLSpecificExpressible : SQLExpressible { extension SQLExpressible where Self: SQLOrderingTerm { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public var reversed: SQLOrderingTerm { return SQLOrdering.desc(sqlExpression) } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func orderingTermSQL(_ arguments: inout StatementArguments?) -> String { return sqlExpression.expressionSQL(&arguments) } @@ -68,16 +76,22 @@ extension SQLExpressible where Self: SQLOrderingTerm { extension SQLExpressible where Self: SQLSelectable { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func resultColumnSQL(_ arguments: inout StatementArguments?) -> String { return sqlExpression.expressionSQL(&arguments) } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func countedSQL(_ arguments: inout StatementArguments?) -> String { return sqlExpression.expressionSQL(&arguments) } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func count(distinct: Bool) -> SQLCount? { return sqlExpression.count(distinct: distinct) } diff --git a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift index 181198f4f..011619517 100644 --- a/GRDB/QueryInterface/SQLExpression+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLExpression+QueryInterface.swift @@ -5,6 +5,8 @@ extension SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// Converts an expression to an SQLExpressionLiteral + /// + /// :nodoc: public var literal: SQLExpressionLiteral { var arguments: StatementArguments? = [] let sql = expressionSQL(&arguments) @@ -57,6 +59,8 @@ public struct SQLExpressionLiteral : SQLExpression { } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func expressionSQL(_ arguments: inout StatementArguments?) -> String { if let literalArguments = self.arguments { guard arguments != nil else { @@ -75,6 +79,8 @@ public struct SQLExpressionLiteral : SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// SQLUnaryOperator is a SQLite unary operator. +/// +/// :nodoc: public struct SQLUnaryOperator : Hashable { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -97,11 +103,15 @@ public struct SQLUnaryOperator : Hashable { } /// The hash value + /// + /// :nodoc: public var hashValue: Int { return sql.hashValue } /// Equality operator + /// + /// :nodoc: public static func == (lhs: SQLUnaryOperator, rhs: SQLUnaryOperator) -> Bool { return lhs.sql == rhs.sql } @@ -113,6 +123,8 @@ public struct SQLUnaryOperator : Hashable { /// an operand expression. /// /// SQLExpressionUnary(.not, Column("favorite")) +/// +/// :nodoc: public struct SQLExpressionUnary : SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -147,6 +159,8 @@ public struct SQLExpressionUnary : SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// SQLBinaryOperator is a SQLite binary operator. +/// +/// :nodoc: public struct SQLBinaryOperator : Hashable { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -223,6 +237,8 @@ public struct SQLBinaryOperator : Hashable { /// binary operator. /// /// SQLExpressionBinary(.multiply, Column("length"), Column("width")) +/// +/// :nodoc: public struct SQLExpressionBinary : SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// @@ -420,6 +436,8 @@ public struct SQLFunctionName : Hashable { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// The SQL function name + /// + /// :nodoc: public let sql: String /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) @@ -427,16 +445,22 @@ public struct SQLFunctionName : Hashable { /// Creates a function name /// /// SQLFunctionName("ABS") + /// + /// :nodoc: public init(_ sql: String) { self.sql = sql } /// The hash value + /// + /// :nodoc: public var hashValue: Int { return sql.hashValue } /// Equality operator + /// + /// :nodoc: public static func == (lhs: SQLFunctionName, rhs: SQLFunctionName) -> Bool { return lhs.sql == rhs.sql } @@ -448,6 +472,8 @@ public struct SQLFunctionName : Hashable { /// /// // ABS(-1) /// SQLExpressionFunction(.abs, [-1.databaseValue]) +/// +/// :nodoc: public struct SQLExpressionFunction : SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// diff --git a/GRDB/QueryInterface/SQLExpression.swift b/GRDB/QueryInterface/SQLExpression.swift index 1d2275d32..5f69f265c 100644 --- a/GRDB/QueryInterface/SQLExpression.swift +++ b/GRDB/QueryInterface/SQLExpression.swift @@ -16,6 +16,8 @@ /// - SQLExpressionExists /// - SQLExpressionFunction /// - SQLExpressionCollate +/// +/// :nodoc: public protocol SQLExpression : SQLSpecificExpressible, SQLSelectable, SQLOrderingTerm { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) @@ -69,6 +71,7 @@ extension SQLExpression { /// let column = Column("favorite") /// column.negated // NOT favorite /// + /// :nodoc: public var negated: SQLExpression { return SQLExpressionNot(self) } @@ -76,6 +79,8 @@ extension SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// The default implementation returns nil + /// + /// :nodoc: public func matchedRowIds(rowIdName: String?) -> Set? { return nil } @@ -86,6 +91,8 @@ extension SQLExpression { extension SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public var sqlExpression: SQLExpression { return self } @@ -96,6 +103,8 @@ extension SQLExpression { extension SQLExpression { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func count(distinct: Bool) -> SQLCount? { if distinct { // SELECT DISTINCT expr FROM tableName ... diff --git a/GRDB/QueryInterface/SQLOrdering.swift b/GRDB/QueryInterface/SQLOrdering.swift index 2fc88addd..e3e8624ba 100644 --- a/GRDB/QueryInterface/SQLOrdering.swift +++ b/GRDB/QueryInterface/SQLOrdering.swift @@ -4,6 +4,8 @@ /// /// The protocol for all types that can be used as an SQL ordering term, as /// described at https://www.sqlite.org/syntax/ordering-term.html +/// +/// :nodoc: public protocol SQLOrderingTerm { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// diff --git a/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift b/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift index 9634bba8b..31369ca9c 100644 --- a/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift +++ b/GRDB/QueryInterface/SQLSelectable+QueryInterface.swift @@ -21,16 +21,22 @@ public struct AllColumns { extension AllColumns : SQLSelectable { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func resultColumnSQL(_ arguments: inout StatementArguments?) -> String { return "*" } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func countedSQL(_ arguments: inout StatementArguments?) -> String { return "*" } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public func count(distinct: Bool) -> SQLCount? { // SELECT DISTINCT * FROM tableName ... guard !distinct else { diff --git a/GRDB/QueryInterface/SQLSelectable.swift b/GRDB/QueryInterface/SQLSelectable.swift index c3492980c..c85b6a207 100644 --- a/GRDB/QueryInterface/SQLSelectable.swift +++ b/GRDB/QueryInterface/SQLSelectable.swift @@ -4,6 +4,8 @@ /// /// SQLSelectable is the protocol for types that can be selected, as /// described at https://www.sqlite.org/syntax/result-column.html +/// +/// :nodoc: public protocol SQLSelectable { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) func resultColumnSQL(_ arguments: inout StatementArguments?) -> String @@ -18,6 +20,8 @@ public protocol SQLSelectable { // MARK: - Counting /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) +/// +/// :nodoc: public enum SQLCount { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// diff --git a/GRDB/QueryInterface/Support/SQLOperators.swift b/GRDB/QueryInterface/Support/SQLOperators.swift index 037e14bde..4dde080e2 100644 --- a/GRDB/QueryInterface/Support/SQLOperators.swift +++ b/GRDB/QueryInterface/Support/SQLOperators.swift @@ -587,7 +587,7 @@ extension SQLBinaryOperator { extension SQLUnaryOperator { /// The `-` unary operator - public static let minus = SQLUnaryOperator("-", needsRightSpace: false) + static let minus = SQLUnaryOperator("-", needsRightSpace: false) } /// An SQL arithmetic multiplication. diff --git a/GRDB/Record/Persistable.swift b/GRDB/Record/Persistable.swift index b739f95c9..cc0d33b55 100644 --- a/GRDB/Record/Persistable.swift +++ b/GRDB/Record/Persistable.swift @@ -13,14 +13,16 @@ extension Database.ConflictResolution { // MARK: - PersistenceError /// An error thrown by a type that adopts Persistable. -public enum PersistenceError: Error { +public enum PersistenceError: Error, CustomStringConvertible { /// Thrown by MutablePersistable.update() when no matching row could be /// found in the database. case recordNotFound(MutablePersistable) } -extension PersistenceError : CustomStringConvertible { +// CustomStringConvertible +extension PersistenceError { + /// :nodoc: public var description: String { switch self { case .recordNotFound(let persistable): @@ -96,6 +98,8 @@ public struct PersistenceContainer { /// Accesses the value associated with the given column, in a /// case-insensitive fashion. + /// + /// :nodoc: subscript(caseInsensitive column: String) -> DatabaseValueConvertible? { get { if let value = storage[column] { diff --git a/GRDB/Record/RecordBox.swift b/GRDB/Record/RecordBox.swift index 106dc4c52..a61c28407 100644 --- a/GRDB/Record/RecordBox.swift +++ b/GRDB/Record/RecordBox.swift @@ -22,8 +22,10 @@ /// playerRecord.persistentChangedValues["score"] // 100 (the old value) /// } public final class RecordBox: Record { + /// The boxed record public var value: T + /// Creates a RecordBox that wraps the given record public init(value: T) { self.value = value super.init() @@ -31,6 +33,7 @@ public final class RecordBox: Record { // MARK: - RowConvertible + /// Initializes a record from `row`. public required init(row: Row) { self.value = T(row: row) super.init(row: row) @@ -38,38 +41,46 @@ public final class RecordBox: Record { // MARK: - TableMapping + /// :nodoc: override public class var databaseTableName: String { return T.databaseTableName } + /// :nodoc: override public class var databaseSelection: [SQLSelectable] { return T.databaseSelection } // MARK: - MutablePersistable + /// :nodoc: override public class var persistenceConflictPolicy: PersistenceConflictPolicy { return T.persistenceConflictPolicy } + /// :nodoc: override public func encode(to container: inout PersistenceContainer) { value.encode(to: &container) } + /// :nodoc: override public func didInsert(with rowID: Int64, for column: String?) { value.didInsert(with: rowID, for: column) } + /// :nodoc: override public func insert(_ db: Database) throws { try value.insert(db) hasPersistentChangedValues = false } + /// :nodoc: override public func update(_ db: Database, columns: Set) throws { try value.update(db, columns: columns) hasPersistentChangedValues = false } + /// :nodoc: @discardableResult override public func delete(_ db: Database) throws -> Bool { defer { @@ -81,6 +92,7 @@ public final class RecordBox: Record { return try value.delete(db) } + /// :nodoc: public func exists(_ db: Database) throws -> Bool { return try value.exists(db) } diff --git a/GRDB/Record/RowConvertible.swift b/GRDB/Record/RowConvertible.swift index ce2fbd098..a6cf9cff4 100644 --- a/GRDB/Record/RowConvertible.swift +++ b/GRDB/Record/RowConvertible.swift @@ -51,6 +51,7 @@ public final class RecordCursor : Cursor { statement.cursorReset(arguments: arguments) } + /// :nodoc: public func next() throws -> Record? { if done { return nil } switch sqlite3_step(sqliteStatement) { diff --git a/GRDB/Utils/Utils.swift b/GRDB/Utils/Utils.swift index 92281cd9b..26cbb66d7 100644 --- a/GRDB/Utils/Utils.swift +++ b/GRDB/Utils/Utils.swift @@ -23,16 +23,24 @@ public func databaseQuestionMarks(count: Int) -> String { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// This protocol is an implementation detail of GRDB. Don't use it. +/// +/// :nodoc: public protocol _OptionalProtocol { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: associatedtype _Wrapped } /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) /// /// This conformance is an implementation detail of GRDB. Don't rely on it. +/// +/// :nodoc: extension Optional : _OptionalProtocol { /// [**Experimental**](http://github.com/groue/GRDB.swift#what-are-experimental-features) + /// + /// :nodoc: public typealias _Wrapped = Wrapped }