[BREAKING] Row refactor

This commit is contained in:
Gwendal Roué committed 2024-04-01 18:17:28 +02:00
1 parent 580f6967d1
commit 66e65db74e
56 files changed
+1794 -1485

No files matched your search

+2 -2
View File
@@ -2169,7 +2169,7 @@ struct BookInfo: FetchableRecord {
var country: Country?
var coverImage: CoverImage?
init(row: Row) throws {
init(row: some RowProtocol) throws {
book = try Book(row: row)
author = row["author"]
country = row["country"]
@@ -2204,7 +2204,7 @@ struct AuthorInfo: FetchableRecord {
var author: Author
var books: [Book]
init(row: Row) throws {
init(row: some RowProtocol) throws {
author = try Author(row: row)
books = row["books"]
}
@@ -75,7 +75,7 @@ struct Place {
// Adopt FetchableRecord
extension Place : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
title = row["title"]
favorite = row["favorite"]
+13 -1
View File
@@ -256,6 +256,8 @@
569BBA3622905FFA00478429 /* InflectionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569BBA3522905FFA00478429 /* InflectionsTests.swift */; };
569BBA4622906A8200478429 /* InflectionsTests.json in Resources */ = {isa = PBXBuildFile; fileRef = 569BBA4522906A8200478429 /* InflectionsTests.json */; };
569BBA4E229170F800478429 /* Inflections+English.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569BBA482291707D00478429 /* Inflections+English.swift */; };
569D55322BBAFE9E00B57CA5 /* DetachedRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569D55312BBAFE9E00B57CA5 /* DetachedRow.swift */; };
569D55342BBAFEC700B57CA5 /* StatementRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569D55332BBAFEC700B57CA5 /* StatementRow.swift */; };
569D6DDE220EF9E100A058A9 /* SQLInterpolation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569D6DDD220EF9E100A058A9 /* SQLInterpolation.swift */; };
569EF0E2200D2D8400A9FA45 /* DatabaseRegion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 569EF0E1200D2D8400A9FA45 /* DatabaseRegion.swift */; };
56A2387B1B9C75030082EB20 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56A238701B9C75030082EB20 /* Configuration.swift */; };
@@ -411,6 +413,7 @@
56F89E152A585C0B002FE2AA /* SQLTableAlterationGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F89E142A585C0B002FE2AA /* SQLTableAlterationGenerator.swift */; };
56FA0C3028B1F2DC00B2DFF7 /* MutablePersistableRecord+Upsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FA0C2F28B1F2DC00B2DFF7 /* MutablePersistableRecord+Upsert.swift */; };
56FA0C3928B20ABE00B2DFF7 /* PersistableRecord+Upsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FA0C3828B20ABE00B2DFF7 /* PersistableRecord+Upsert.swift */; };
56FA602F2BB96AA50085DEB7 /* RowProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FA602E2BB96AA50085DEB7 /* RowProtocol.swift */; };
56FBFEDA2210731A00945324 /* SQLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FBFED82210731A00945324 /* SQLRequest.swift */; };
56FEB8F8248403000081AF83 /* DatabaseTraceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FEB8F6248402E10081AF83 /* DatabaseTraceTests.swift */; };
56FEE7FB1F47253700D930EA /* TableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FEE7FA1F47253700D930EA /* TableRecordTests.swift */; };
@@ -721,6 +724,8 @@
569BBA4522906A8200478429 /* InflectionsTests.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = InflectionsTests.json; sourceTree = "<group>"; };
569BBA482291707D00478429 /* Inflections+English.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Inflections+English.swift"; sourceTree = "<group>"; };
569C1EB11CF07DDD0042627B /* SchedulingWatchdogTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulingWatchdogTests.swift; sourceTree = "<group>"; };
569D55312BBAFE9E00B57CA5 /* DetachedRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetachedRow.swift; sourceTree = "<group>"; };
569D55332BBAFEC700B57CA5 /* StatementRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatementRow.swift; sourceTree = "<group>"; };
569D6DDD220EF9E100A058A9 /* SQLInterpolation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLInterpolation.swift; sourceTree = "<group>"; };
569EF0E1200D2D8400A9FA45 /* DatabaseRegion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseRegion.swift; sourceTree = "<group>"; };
56A238131B9C74A90082EB20 /* DatabaseTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTests.swift; sourceTree = "<group>"; };
@@ -846,6 +851,7 @@
56F89E142A585C0B002FE2AA /* SQLTableAlterationGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLTableAlterationGenerator.swift; sourceTree = "<group>"; };
56FA0C2F28B1F2DC00B2DFF7 /* MutablePersistableRecord+Upsert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MutablePersistableRecord+Upsert.swift"; sourceTree = "<group>"; };
56FA0C3828B20ABE00B2DFF7 /* PersistableRecord+Upsert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PersistableRecord+Upsert.swift"; sourceTree = "<group>"; };
56FA602E2BB96AA50085DEB7 /* RowProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowProtocol.swift; sourceTree = "<group>"; };
56FBFED82210731A00945324 /* SQLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLRequest.swift; sourceTree = "<group>"; };
56FDECE11BB32DFD009AD709 /* RowFromStatementTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFromStatementTests.swift; sourceTree = "<group>"; };
56FEB8F6248402E10081AF83 /* DatabaseTraceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseTraceTests.swift; sourceTree = "<group>"; };
@@ -1585,13 +1591,15 @@
56A238751B9C75030082EB20 /* DatabaseValue.swift */,
560D923E1C672C3E00F4F92B /* DatabaseValueConvertible.swift */,
563363C31C942C37000BE133 /* DatabaseWriter.swift */,
569D55312BBAFE9E00B57CA5 /* DetachedRow.swift */,
569D55332BBAFEC700B57CA5 /* StatementRow.swift */,
5636E9BB1D22574100B9B05F /* FetchRequest.swift */,
56A238761B9C75030082EB20 /* Row.swift */,
567404871CEF84C8003ED5CC /* RowAdapter.swift */,
566B9C1F25C6CC24004542CF /* RowDecodingError.swift */,
56FA602E2BB96AA50085DEB7 /* RowProtocol.swift */,
56BB6EA81D3009B100A1CA52 /* SchedulingWatchdog.swift */,
560A37A61C8FF6E500949E71 /* SerializedDatabase.swift */,
56D3331F29C38D6700430680 /* WALSnapshotTransaction.swift */,
56E9FAD7221053DC00C703A8 /* SQL.swift */,
569D6DDD220EF9E100A058A9 /* SQLInterpolation.swift */,
56FBFED82210731A00945324 /* SQLRequest.swift */,
@@ -1601,6 +1609,7 @@
56AFEF2E29969F6E00CA1E51 /* TransactionClock.swift */,
566B91321FA4D3810012D5B0 /* TransactionObserver.swift */,
56B7EE822863781300C0525F /* WALSnapshot.swift */,
56D3331F29C38D6700430680 /* WALSnapshotTransaction.swift */,
5605F1471C672E4000235C62 /* Support */,
);
path = Core;
@@ -2229,6 +2238,7 @@
563B8FAC24A1CE43007A48C9 /* DatabasePublishers.swift in Sources */,
56F89E0C2A57EC16002FE2AA /* SQLTableGenerator.swift in Sources */,
56F89DFC2A57EAEA002FE2AA /* ForeignKeyDefinition.swift in Sources */,
569D55322BBAFE9E00B57CA5 /* DetachedRow.swift in Sources */,
56FA0C3028B1F2DC00B2DFF7 /* MutablePersistableRecord+Upsert.swift in Sources */,
5605F1691C672E4000235C62 /* NSString.swift in Sources */,
560D92401C672C3E00F4F92B /* DatabaseValueConvertible.swift in Sources */,
@@ -2263,6 +2273,7 @@
5656A8AD2295BFD7001FF3FF /* TableRecord+Association.swift in Sources */,
56D110C428AFC5A800E64463 /* MutablePersistableRecord+Update.swift in Sources */,
5690C3401D23E82A00E59934 /* Data.swift in Sources */,
56FA602F2BB96AA50085DEB7 /* RowProtocol.swift in Sources */,
5659F4881EA8D94E004A4992 /* Utils.swift in Sources */,
567B5BE82AD3284100629622 /* DumpFormat.swift in Sources */,
566BE71E2342542F00A8254B /* Mutex.swift in Sources */,
@@ -2319,6 +2330,7 @@
567B5BEC2AD3284100629622 /* Database+Dump.swift in Sources */,
56CEB5531EAA359A00BFAF62 /* SQLExpression.swift in Sources */,
567B5BEB2AD3284100629622 /* DebugDumpFormat.swift in Sources */,
569D55342BBAFEC700B57CA5 /* StatementRow.swift in Sources */,
56B9649D1DA51B4C0002DA19 /* FTS5.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
+4 -4
View File
@@ -1072,7 +1072,7 @@ public struct ColumnInfo: FetchableRecord, Sendable {
/// For columns that are not part of the primary key, it is zero.
public let primaryKeyIndex: Int
public init(row: Row) {
public init(row: some RowProtocol) {
cid = row["cid"]
name = row["name"]
type = row["type"]
@@ -1238,7 +1238,7 @@ public struct ForeignKeyViolation: Sendable {
}
extension ForeignKeyViolation: FetchableRecord {
public init(row: Row) {
public init(row: some RowProtocol) {
originTable = row[0]
originRowID = row[1]
destinationTable = row[2]
@@ -1481,7 +1481,7 @@ struct TableInfo: FetchableRecord {
var hasRowID: Bool
var strict: Bool
init(row: Row) throws {
init(row: some RowProtocol) throws {
switch row[0] as String {
case "main":
schemaID = .main
@@ -1515,7 +1515,7 @@ struct SchemaObject: Hashable, FetchableRecord {
var tbl_name: String?
var sql: String?
init(row: Row) throws {
init(row: some RowProtocol) throws {
// "rootpage" column is not always there: avoid using numerical indexes
type = row["type"]
name = row["name"]
+13 -39
View File
@@ -129,45 +129,20 @@ extension DatabaseValueConvertible {
// MARK: - Conversions
extension DatabaseValueConvertible {
static func decode(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Self
{
if let value = fromDatabaseValue(dbValue) {
@inlinable
public static func _decode(
databaseValue: DatabaseValue,
context: @autoclosure () -> _RowDecodingContext
) throws -> Self {
if let value = fromDatabaseValue(databaseValue) {
return value
} else {
throw RowDecodingError.valueMismatch(Self.self, context: context(), databaseValue: dbValue)
throw RowDecodingError.valueMismatch(
Self.self,
context: context(),
databaseValue: databaseValue)
}
}
static func decode(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Self
{
let dbValue = DatabaseValue(sqliteStatement: sqliteStatement, index: index)
return try decode(fromDatabaseValue: dbValue, context: context())
}
@usableFromInline
static func decode(fromRow row: Row, atUncheckedIndex index: Int) throws -> Self {
if let sqliteStatement = row.sqliteStatement {
return try decode(
fromStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
return try decode(
fromDatabaseValue: row.impl.databaseValue(atUncheckedIndex: index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
@usableFromInline
static func decodeIfPresent(fromRow row: Row, atUncheckedIndex index: Int) throws -> Self? {
try Optional<Self>.decode(fromRow: row, atUncheckedIndex: index)
}
}
// MARK: - Cursors
@@ -215,10 +190,9 @@ public final class DatabaseValueCursor<Value: DatabaseValueConvertible>: Databas
}
public func _element(sqliteStatement: SQLiteStatement) throws -> Value {
try Value.decode(
fromStatement: sqliteStatement,
atUncheckedIndex: columnIndex,
context: RowDecodingContext(statement: _statement, index: Int(columnIndex)))
try Value._decode(
databaseValue: DatabaseValue(sqliteStatement: sqliteStatement, index: columnIndex),
context: _RowDecodingContext(statement: _statement, index: Int(columnIndex)))
}
}
+8
View File
@@ -0,0 +1,8 @@
//#warning("TODO: document")
//struct DetachedRow {
//
//}
//
//extension DetachedRow: Row {
//
//}
+118 -973
View File
File diff suppressed because it is too large. Load diff
+3 -3
View File
@@ -83,7 +83,7 @@ import Foundation
/// }
///
/// extension PlayerInfo: FetchableRecord {
/// init(row: Row) {
/// init(row: some RowProtocol) {
/// player = row["player"]
/// team = row["team"]
/// }
@@ -698,7 +698,7 @@ struct AdaptedRowImpl: RowImpl {
var count: Int { mapping._layoutColumns.count }
var isFetched: Bool { base.isFetched }
var isFetched: Bool { base._isFetched }
func scopes(prefetchedRows: Row.PrefetchedRowsView) -> Row.ScopesView {
Row.ScopesView(row: base, scopes: adapter._scopes, prefetchedRows: prefetchedRows)
@@ -720,7 +720,7 @@ struct AdaptedRowImpl: RowImpl {
throws -> Value
{
let mappedIndex = mapping.baseColumnIndex(atMappingIndex: index)
return try Value.fastDecode(fromRow: base, atUncheckedIndex: mappedIndex)
return try base._fastDecode(Value.self, atUncheckedIndex: mappedIndex)
}
func withUnsafeData<T>(atUncheckedIndex index: Int, _ body: (Data?) throws -> T) throws -> T {
+14 -33
View File
@@ -8,8 +8,7 @@ import SQLite3
#endif
/// A key that is used to decode a value in a row
@usableFromInline
enum RowKey: Hashable, Sendable {
public enum _RowKey: Hashable, Sendable {
/// A column name
case columnName(String)
@@ -38,7 +37,7 @@ enum RowDecodingError: Error {
var row: Row { Row(impl: rowImpl) }
/// Nil for RowDecodingError.keyNotFound, in order to avoid redundancy
let key: RowKey?
let key: _RowKey?
/// The SQL query
let sql: String?
@@ -46,7 +45,7 @@ enum RowDecodingError: Error {
/// The SQL query arguments
let statementArguments: StatementArguments?
init(decodingContext: RowDecodingContext, debugDescription: String) {
init(decodingContext: _RowDecodingContext, debugDescription: String) {
self.debugDescription = debugDescription
self.rowImpl = ArrayRowImpl(columns: decodingContext.row)
self.key = decodingContext.key
@@ -55,7 +54,7 @@ enum RowDecodingError: Error {
}
}
case keyNotFound(RowKey, Context)
case keyNotFound(_RowKey, Context)
case valueMismatch(Any.Type, Context)
var context: Context {
@@ -68,9 +67,10 @@ enum RowDecodingError: Error {
/// Convenience method that builds the
/// `could not decode <Type> from database value <value>` error message.
@usableFromInline
static func valueMismatch(
_ type: Any.Type,
context: RowDecodingContext,
context: _RowDecodingContext,
databaseValue: DatabaseValue)
-> Self
{
@@ -88,7 +88,7 @@ enum RowDecodingError: Error {
_ type: Any.Type,
sqliteStatement: SQLiteStatement,
index: CInt,
context: RowDecodingContext)
context: _RowDecodingContext)
-> Self
{
valueMismatch(
@@ -107,14 +107,14 @@ enum RowDecodingError: Error {
{
valueMismatch(
type,
context: RowDecodingContext(statement: statement, index: index),
context: _RowDecodingContext(statement: statement, index: index),
databaseValue: DatabaseValue(sqliteStatement: statement.sqliteStatement, index: CInt(index)))
}
/// Convenience method that builds the `column not found: <column>`
/// error message.
@usableFromInline
static func columnNotFound(_ columnName: String, context: RowDecodingContext) -> Self {
static func columnNotFound(_ columnName: String, context: _RowDecodingContext) -> Self {
keyNotFound(
.columnName(columnName),
RowDecodingError.Context(decodingContext: context, debugDescription: """
@@ -123,39 +123,20 @@ enum RowDecodingError: Error {
}
}
@usableFromInline
struct RowDecodingContext {
public struct _RowDecodingContext {
/// The row that is decoded
let row: Row
let key: RowKey?
let key: _RowKey?
/// The SQL query
let sql: String?
/// The SQL query arguments
let statementArguments: StatementArguments?
@usableFromInline
init(row: Row, key: RowKey? = nil) {
if let statement = row.statement {
self.key = key
self.row = row.copy()
self.sql = statement.sql
self.statementArguments = statement.arguments
} else if let sqliteStatement = row.sqliteStatement {
self.key = key
self.row = row.copy()
self.sql = String(cString: sqlite3_sql(sqliteStatement)).trimmedSQLStatement
self.statementArguments = nil // Can't rebuild them
} else {
self.key = key
self.row = row.copy()
self.sql = nil
self.statementArguments = nil
}
}
}
extension _RowDecodingContext {
/// Convenience initializer
@usableFromInline
init(statement: Statement, index: Int) {
File diff suppressed because it is too large. Load diff
+17 -58
View File
@@ -32,7 +32,7 @@ import SQLite3
/// var name: String
/// var score: Int
///
/// init(row: Row) {
/// init(row: some RowProtocol) {
/// // Optimized
/// name = row["name"]
/// score = row["score"]
@@ -136,62 +136,21 @@ extension StatementColumnConvertible {
// MARK: - Conversions
extension DatabaseValueConvertible where Self: StatementColumnConvertible {
@usableFromInline
/* private */ static func _valueMismatch(
fromStatement sqliteStatement: SQLiteStatement,
extension StatementColumnConvertible {
@inlinable
public static func _fastDecode(
sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Never
{
throw RowDecodingError.valueMismatch(
Self.self,
sqliteStatement: sqliteStatement,
index: index,
context: context())
}
@inline(__always)
@inlinable
static func fastDecode(
fromRow row: Row,
atUncheckedIndex index: Int)
throws -> Self
{
if let sqliteStatement = row.sqliteStatement {
return try fastDecode(
fromStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
context: @autoclosure () -> _RowDecodingContext
) throws -> Self {
guard let value = fromStatement(sqliteStatement, atUncheckedIndex: index) else {
throw RowDecodingError.valueMismatch(
Self.self,
sqliteStatement: sqliteStatement,
index: index,
context: context())
}
// Support for fast decoding from adapted rows
return try row.fastDecode(Self.self, atUncheckedIndex: index)
}
@inline(__always)
@inlinable
static func fastDecode(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Self
{
if let value = fromStatement(sqliteStatement, atUncheckedIndex: index) {
return value
} else {
try _valueMismatch(fromStatement: sqliteStatement, atUncheckedIndex: index, context: context())
}
}
// Support for Decodable
@inline(__always)
@inlinable
static func fastDecodeIfPresent(
fromRow row: Row,
atUncheckedIndex index: Int)
throws -> Self?
{
try Optional<Self>.fastDecode(fromRow: row, atUncheckedIndex: index)
return value
}
}
@@ -243,10 +202,10 @@ where Value: DatabaseValueConvertible & StatementColumnConvertible
@inlinable
public func _element(sqliteStatement: SQLiteStatement) throws -> Value {
try Value.fastDecode(
fromStatement: sqliteStatement,
try Value._fastDecode(
sqliteStatement: sqliteStatement,
atUncheckedIndex: columnIndex,
context: RowDecodingContext(statement: _statement, index: Int(columnIndex)))
context: _RowDecodingContext(statement: _statement, index: Int(columnIndex)))
}
}
+152
View File
@@ -0,0 +1,152 @@
#if SWIFT_PACKAGE
import CSQLite
#elseif GRDBCIPHER
import SQLCipher
#elseif !GRDBCUSTOMSQLITE && !GRDBCIPHER
import SQLite3
#endif
import Foundation
#warning("TODO: document")
final class StatementRow {
private let statement: Statement
private let sqliteStatement: SQLiteStatement
private let lowercaseColumnIndexes: [String: Int]
init(statement: Statement) {
let sqliteStatement = statement.sqliteStatement
self.statement = statement
self.sqliteStatement = sqliteStatement
// Optimize index(forColumn:)
let lowercaseColumnNames = (0..<sqlite3_column_count(sqliteStatement))
.map { String(cString: sqlite3_column_name(sqliteStatement, CInt($0))).lowercased() }
self.lowercaseColumnIndexes = Dictionary(
lowercaseColumnNames
.enumerated()
.map { ($0.element, $0.offset) },
uniquingKeysWith: { (left, _) in left }) // keep leftmost indexes
}
}
extension StatementRow: RowProtocol {
typealias Index = RowIndex
typealias Element = (String, DatabaseValue)
var prefetchedRows: Row.PrefetchedRowsView {
Row.PrefetchedRowsView()
}
#warning("TODO: wrong return type")
func copy() -> Row {
Row(copiedFromSQLiteStatement: sqliteStatement, statement: statement)
}
func _decode<Strategy: _RowDecodingStrategy>(
with strategy: Strategy,
atUncheckedIndex index: Int
) throws -> Strategy._RowDecodingOutput
{
let statementIndex = CInt(index)
if sqlite3_column_type(sqliteStatement, statementIndex) == SQLITE_NULL {
throw RowDecodingError.valueMismatch(
Strategy._RowDecodingOutput.self,
sqliteStatement: sqliteStatement,
index: statementIndex,
context: _makeRowDecodingContext(forKey: .columnIndex(index)))
}
return try strategy._decode(
sqliteStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: _makeRowDecodingContext(forKey: .columnIndex(index)))
}
func _decode<Value: DatabaseValueConvertible>(
_ type: Value.Type,
atUncheckedIndex index: Int
) throws -> Value
{
try Value._decode(
databaseValue: _databaseValue(atUncheckedIndex: index),
context: _makeRowDecodingContext(forKey: .columnIndex(index)))
}
func _fastDecode<Value: DatabaseValueConvertible & StatementColumnConvertible>(
_ type: Value.Type,
atUncheckedIndex index: Int
) throws -> Value
{
try Value._fastDecode(
sqliteStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: _RowDecodingContext(statement: statement, index: index))
}
var _isFetched: Bool {
true
}
func _scopes(prefetchedRows: Row.PrefetchedRowsView) -> Row.ScopesView {
Row.ScopesView()
}
func _columnName(atUncheckedIndex index: Int) -> String {
statement.columnNames[index]
}
func _hasNull(atUncheckedIndex index: Int) -> Bool {
// Avoid extracting values, because this modifies the SQLite statement.
sqlite3_column_type(sqliteStatement, CInt(index)) == SQLITE_NULL
}
func _databaseValue(atUncheckedIndex index: Int) -> DatabaseValue {
DatabaseValue(sqliteStatement: sqliteStatement, index: CInt(index))
}
func _withUnsafeData<T>(atUncheckedIndex index: Int, _ body: (Data?) throws -> T) throws -> T {
guard sqlite3_column_type(sqliteStatement, CInt(index)) != SQLITE_NULL else {
return try body(nil)
}
guard let bytes = sqlite3_column_blob(sqliteStatement, CInt(index)) else {
return try body(Data())
}
let count = Int(sqlite3_column_bytes(sqliteStatement, CInt(index)))
let data = Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes), count: count, deallocator: .none)
return try body(data)
}
#warning("TODO: wrong return type")
var _unscopedRow: Row {
copy()
}
#warning("TODO: wrong return type")
var _unadaptedRow: Row {
copy()
}
#warning("TODO: wrong return type")
var _copiedRow: Row {
copy()
}
func _makeRowDecodingContext(forKey key: _RowKey?) -> _RowDecodingContext {
_RowDecodingContext(
row: copy(),
key: key,
sql: statement.sql,
statementArguments: statement.arguments)
}
func index(forColumn name: String) -> Int? {
if let index = lowercaseColumnIndexes[name] {
return index
}
return lowercaseColumnIndexes[name.lowercased()]
}
}
-24
View File
@@ -69,27 +69,3 @@ extension Data: DatabaseValueConvertible, StatementColumnConvertible {
}
}
}
// MARK: - Conversions
extension Data {
static func fastDecodeNoCopy(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Data
{
guard sqlite3_column_type(sqliteStatement, index) != SQLITE_NULL else {
throw RowDecodingError.valueMismatch(
Data.self,
sqliteStatement: sqliteStatement,
index: index,
context: context())
}
guard let bytes = sqlite3_column_blob(sqliteStatement, index) else {
return Data()
}
let count = Int(sqlite3_column_bytes(sqliteStatement, index))
return Data(bytesNoCopy: UnsafeMutableRawPointer(mutating: bytes), count: count, deallocator: .none)
}
}
+75 -189
View File
@@ -11,7 +11,7 @@ import Foundation
extension FetchableRecord where Self: Decodable {
/// Creates a record from `row`, using the `Decodable` conformance.
public init(row: Row) throws {
public init(row: some RowProtocol) throws {
self = try FetchableRecordDecoder().decode(Self.self, from: row)
}
}
@@ -78,17 +78,26 @@ public class FetchableRecordDecoder {
/// - row: The database row to decode.
/// - Returns: An instance of the specified record type, if the decoder
/// can parse the database row.
public func decode<T: FetchableRecord & Decodable>(_ type: T.Type, from row: Row) throws -> T {
let decoder = _RowDecoder<T>(row: row, codingPath: [], columnDecodingStrategy: T.databaseColumnDecodingStrategy)
public func decode<RowType: RowProtocol, T: FetchableRecord & Decodable>(_ type: T.Type, from row: RowType) throws -> T {
let decoder = _RowDecoder<RowType, T>(row: row, codingPath: [], columnDecodingStrategy: T.databaseColumnDecodingStrategy)
return try T(from: decoder)
}
}
#warning("TODO: fetch if correct")
private struct NestedDecodingContext<R: FetchableRecord>: FetchableRecord {
init(row: some RowProtocol) throws { preconditionFailure() }
static var databaseColumnDecodingStrategy: DatabaseColumnDecodingStrategy { R.databaseColumnDecodingStrategy }
static var databaseDecodingUserInfo: [CodingUserInfoKey: Any] { R.databaseDecodingUserInfo }
static var databaseDataDecodingStrategy: DatabaseDataDecodingStrategy { R.databaseDataDecodingStrategy }
static var databaseDateDecodingStrategy: DatabaseDateDecodingStrategy { R.databaseDateDecodingStrategy }
}
// MARK: - _RowDecoder
/// The decoder that decodes a record from a database row
private struct _RowDecoder<R: FetchableRecord>: Decoder {
var row: Row
private struct _RowDecoder<RowType: RowProtocol, R: FetchableRecord>: Decoder {
var row: RowType
var codingPath: [CodingKey]
var columnDecodingStrategy: DatabaseColumnDecodingStrategy
var userInfo: [CodingUserInfoKey: Any] { R.databaseDecodingUserInfo }
@@ -118,17 +127,17 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
func singleValueContainer() throws -> SingleValueDecodingContainer {
guard let key = codingPath.last else {
// Decoding an array of scalars from rows: pick the first column
return ColumnDecoder<R>(row: row, columnIndex: 0, codingPath: codingPath)
return ColumnDecoder<RowType, R>(row: row, columnIndex: 0, codingPath: codingPath)
}
guard let index = row.index(forColumn: key.stringValue) else {
// Don't use DecodingError.keyNotFound:
// We need to specifically recognize missing columns in order to
// provide correct feedback.
throw RowDecodingError.columnNotFound(key.stringValue, context: RowDecodingContext(row: row))
throw RowDecodingError.columnNotFound(key.stringValue, context: row._makeRowDecodingContext(forKey: nil))
}
// TODO: test
// See DatabaseValueConversionErrorTests.testDecodableFetchableRecord2
return ColumnDecoder<R>(row: row, columnIndex: index, codingPath: codingPath)
return ColumnDecoder<RowType, R>(row: row, columnIndex: index, codingPath: codingPath)
}
class KeyedContainer<Key: CodingKey>: KeyedDecodingContainerProtocol {
@@ -248,12 +257,12 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
}
// TODO: this is not quite correct: key IS NOT a column name.
// So we shouldn't use RowKey.columnName. Yet this only impacts
// So we shouldn't use _RowKey.columnName. Yet this only impacts
// internal types, so the damage is limited.
throw RowDecodingError.keyNotFound(
.columnName(key.stringValue), // <- See above TODO
RowDecodingError.Context(
decodingContext: RowDecodingContext(row: decoder.row),
decodingContext: decoder.row._makeRowDecodingContext(forKey: nil),
debugDescription: "key not found: \(errorDescription)"))
}
@@ -270,18 +279,18 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
// Prefer DatabaseValueConvertible decoding over Decodable.
// This allows decoding Date from String, or DatabaseValue from NULL.
if type == Data.self {
return try R.databaseDataDecodingStrategy.decodeIfPresent(
fromRow: row,
return try row._decodeIfPresent(
with: R.databaseDataDecodingStrategy,
atUncheckedIndex: index) as! T?
} else if type == Date.self {
return try R.databaseDateDecodingStrategy.decodeIfPresent(
fromRow: row,
return try row._decodeIfPresent(
with: R.databaseDateDecodingStrategy,
atUncheckedIndex: index) as! T?
} else if let type = T.self as? any (DatabaseValueConvertible & StatementColumnConvertible).Type {
return try type.fastDecodeIfPresent(fromRow: row, atUncheckedIndex: index) as! T?
return try row._fastDecodeIfPresent(type, atUncheckedIndex: index) as! T?
} else if let type = T.self as? any DatabaseValueConvertible.Type {
return try type.decodeIfPresent(fromRow: row, atUncheckedIndex: index) as! T?
} else if row.impl.hasNull(atUncheckedIndex: index) {
return try row._decodeIfPresent(type, atUncheckedIndex: index) as! T?
} else if row._hasNull(atUncheckedIndex: index) {
return nil
} else {
return try decode(type, fromRow: row, columnAtIndex: index, key: key)
@@ -319,13 +328,13 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
// Prefer DatabaseValueConvertible decoding over Decodable.
// This allows decoding Date from String, or DatabaseValue from NULL.
if type == Data.self {
return try R.databaseDataDecodingStrategy.decode(fromRow: row, atUncheckedIndex: index) as! T
return try row._decode(with: R.databaseDataDecodingStrategy, atUncheckedIndex: index) as! T
} else if type == Date.self {
return try R.databaseDateDecodingStrategy.decode(fromRow: row, atUncheckedIndex: index) as! T
return try row._decode(with: R.databaseDateDecodingStrategy, atUncheckedIndex: index) as! T
} else if let type = T.self as? any (DatabaseValueConvertible & StatementColumnConvertible).Type {
return try type.fastDecode(fromRow: row, atUncheckedIndex: index) as! T
return try row._fastDecode(type, atUncheckedIndex: index) as! T
} else if let type = T.self as? any DatabaseValueConvertible.Type {
return try type.decode(fromRow: row, atUncheckedIndex: index) as! T
return try row._decode(type, atUncheckedIndex: index) as! T
} else {
return try decode(type, fromRow: row, columnAtIndex: index, key: key)
}
@@ -404,9 +413,10 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
// Helper methods
private func decode<T>(
#warning("TODO: make NestedRowType concrete once it is settled")
private func decode<NestedRowType: RowProtocol, T>(
_ type: T.Type,
fromRow row: Row,
fromRow row: NestedRowType,
codingPath: [CodingKey])
throws -> T
where T: Decodable
@@ -415,14 +425,14 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
// Prefer FetchableRecord decoding over Decodable.
return try type.init(row: row) as! T
} else {
let decoder = _RowDecoder(row: row, codingPath: codingPath, columnDecodingStrategy: .useDefaultKeys)
let decoder = _RowDecoder<NestedRowType, NestedDecodingContext<R>>(row: row, codingPath: codingPath, columnDecodingStrategy: .useDefaultKeys)
return try T(from: decoder)
}
}
private func decode<T>(
_ type: T.Type,
fromRow row: Row,
fromRow row: RowType,
columnAtIndex index: Int,
key: Key)
throws -> T
@@ -433,7 +443,7 @@ private struct _RowDecoder<R: FetchableRecord>: Decoder {
// or unkeyed containers, because we're decoding a single
// value here (string, int, double, data, null). If such an
// error happens, we'll switch to JSON decoding.
let columnDecoder = ColumnDecoder<R>(
let columnDecoder = ColumnDecoder<RowType, R>(
row: row,
columnIndex: index,
codingPath: codingPath + [key])
@@ -497,7 +507,7 @@ extension PrefetchedRowsDecoder: UnkeyedDecodingContainer {
columnDecodingStrategy = .useDefaultKeys
}
let decoder = _RowDecoder<R>(
let decoder = _RowDecoder<Row, R>(
row: rows[currentIndex],
codingPath: codingPath,
columnDecodingStrategy: columnDecodingStrategy)
@@ -523,8 +533,8 @@ extension PrefetchedRowsDecoder: UnkeyedDecodingContainer {
// MARK: - ColumnDecoder
/// The decoder that decodes from a database column
private struct ColumnDecoder<R: FetchableRecord>: Decoder {
var row: Row
private struct ColumnDecoder<RowType: RowProtocol, R: FetchableRecord>: Decoder {
var row: RowType
var columnIndex: Int
var codingPath: [CodingKey]
var userInfo: [CodingUserInfoKey: Any] { R.databaseDecodingUserInfo }
@@ -565,13 +575,13 @@ extension ColumnDecoder: SingleValueDecodingContainer {
func decode<T>(_ type: T.Type) throws -> T where T: Decodable {
// TODO: not tested
if type == Data.self {
return try R.databaseDataDecodingStrategy.decode(fromRow: row, atUncheckedIndex: columnIndex) as! T
return try row._decode(with: R.databaseDataDecodingStrategy, atUncheckedIndex: columnIndex) as! T
} else if type == Date.self {
return try R.databaseDateDecodingStrategy.decode(fromRow: row, atUncheckedIndex: columnIndex) as! T
return try row._decode(with: R.databaseDateDecodingStrategy, atUncheckedIndex: columnIndex) as! T
} else if let type = T.self as? any (DatabaseValueConvertible & StatementColumnConvertible).Type {
return try type.fastDecode(fromRow: row, atUncheckedIndex: columnIndex) as! T
return try row._fastDecode(type, atUncheckedIndex: columnIndex) as! T
} else if let type = T.self as? any DatabaseValueConvertible.Type {
return try type.decode(fromRow: row, atUncheckedIndex: columnIndex) as! T
return try row._decode(type, atUncheckedIndex: columnIndex) as! T
} else {
return try T(from: self)
}
@@ -584,50 +594,12 @@ private let iso8601Formatter: ISO8601DateFormatter = {
return formatter
}()
extension DatabaseDataDecodingStrategy {
fileprivate func decodeIfPresent(fromRow row: Row, atUncheckedIndex index: Int) throws -> Data? {
if let sqliteStatement = row.sqliteStatement {
return try decodeIfPresent(
fromStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
} else {
return try decodeIfPresent(
fromDatabaseValue: row[index],
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
}
fileprivate func decode(fromRow row: Row, atUncheckedIndex index: Int) throws -> Data {
if let sqliteStatement = row.sqliteStatement {
let statementIndex = CInt(index)
if sqlite3_column_type(sqliteStatement, statementIndex) == SQLITE_NULL {
throw RowDecodingError.valueMismatch(
Data.self,
sqliteStatement: sqliteStatement,
index: statementIndex,
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
return try decode(
fromStatement: sqliteStatement,
atUncheckedIndex: statementIndex,
context: RowDecodingContext(row: row, key: .columnIndex(index)))
} else {
return try decode(
fromDatabaseValue: row[index],
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
}
/// - precondition: value is not NULL
fileprivate func decode(
fromStatement sqliteStatement: SQLiteStatement,
extension DatabaseDataDecodingStrategy: _RowDecodingStrategy {
public func _decode(
sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Data
{
context: @autoclosure () -> _RowDecodingContext
) throws -> Data {
assert(sqlite3_column_type(sqliteStatement, index) != SQLITE_NULL, "unexpected NULL value")
switch self {
case .deferredToData:
@@ -644,46 +616,22 @@ extension DatabaseDataDecodingStrategy {
}
}
fileprivate func decodeIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Data?
{
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
return nil
}
return try decode(fromStatement: sqliteStatement, atUncheckedIndex: index, context: context())
}
fileprivate func decode(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Data
{
if let data = dataFromDatabaseValue(dbValue) {
public func _decode(
databaseValue: DatabaseValue,
context: @autoclosure () -> _RowDecodingContext
) throws -> Data {
if let data = decode(databaseValue) {
return data
} else {
throw RowDecodingError.valueMismatch(Data.self, context: context(), databaseValue: dbValue)
throw RowDecodingError.valueMismatch(
Data.self,
context: context(),
databaseValue: databaseValue)
}
}
fileprivate func decodeIfPresent(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Data?
{
if dbValue.isNull {
return nil
} else if let data = dataFromDatabaseValue(dbValue) {
return data
} else {
throw RowDecodingError.valueMismatch(Data.self, context: context(), databaseValue: dbValue)
}
}
// Returns nil if decoding fails
private func dataFromDatabaseValue(_ dbValue: DatabaseValue) -> Data? {
/// Returns nil if decoding fails
private func decode(_ dbValue: DatabaseValue) -> Data? {
switch self {
case .deferredToData:
return Data.fromDatabaseValue(dbValue)
@@ -693,50 +641,12 @@ extension DatabaseDataDecodingStrategy {
}
}
extension DatabaseDateDecodingStrategy {
fileprivate func decodeIfPresent(fromRow row: Row, atUncheckedIndex index: Int) throws -> Date? {
if let sqliteStatement = row.sqliteStatement {
return try decodeIfPresent(
fromStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
} else {
return try decodeIfPresent(
fromDatabaseValue: row[index],
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
}
fileprivate func decode(fromRow row: Row, atUncheckedIndex index: Int) throws -> Date {
if let sqliteStatement = row.sqliteStatement {
let statementIndex = CInt(index)
if sqlite3_column_type(sqliteStatement, statementIndex) == SQLITE_NULL {
throw RowDecodingError.valueMismatch(
Date.self,
sqliteStatement: sqliteStatement,
index: statementIndex,
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
return try decode(
fromStatement: sqliteStatement,
atUncheckedIndex: CInt(index),
context: RowDecodingContext(row: row, key: .columnIndex(index)))
} else {
return try decode(
fromDatabaseValue: row[index],
context: RowDecodingContext(row: row, key: .columnIndex(index)))
}
}
/// - precondition: value is not NULL
fileprivate func decode(
fromStatement sqliteStatement: SQLiteStatement,
extension DatabaseDateDecodingStrategy: _RowDecodingStrategy {
public func _decode(
sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Date
{
context: @autoclosure () -> _RowDecodingContext
) throws -> Date {
assert(sqlite3_column_type(sqliteStatement, index) != SQLITE_NULL, "unexpected NULL value")
switch self {
case .deferredToDate:
@@ -786,46 +696,22 @@ extension DatabaseDateDecodingStrategy {
}
}
fileprivate func decodeIfPresent(
fromStatement sqliteStatement: SQLiteStatement,
atUncheckedIndex index: CInt,
context: @autoclosure () -> RowDecodingContext)
throws -> Date?
{
if sqlite3_column_type(sqliteStatement, index) == SQLITE_NULL {
return nil
}
return try decode(fromStatement: sqliteStatement, atUncheckedIndex: index, context: context())
}
fileprivate func decode(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Date
{
if let date = dateFromDatabaseValue(dbValue) {
public func _decode(
databaseValue: DatabaseValue,
context: @autoclosure () -> _RowDecodingContext
) throws -> Date {
if let date = decode(databaseValue) {
return date
} else {
throw RowDecodingError.valueMismatch(Date.self, context: context(), databaseValue: dbValue)
throw RowDecodingError.valueMismatch(
Date.self,
context: context(),
databaseValue: databaseValue)
}
}
fileprivate func decodeIfPresent(
fromDatabaseValue dbValue: DatabaseValue,
context: @autoclosure () -> RowDecodingContext)
throws -> Date?
{
if dbValue.isNull {
return nil
} else if let date = dateFromDatabaseValue(dbValue) {
return date
} else {
throw RowDecodingError.valueMismatch(Date.self, context: context(), databaseValue: dbValue)
}
}
// Returns nil if decoding fails
private func dateFromDatabaseValue(_ dbValue: DatabaseValue) -> Date? {
/// Returns nil if decoding fails
private func decode(_ dbValue: DatabaseValue) -> Date? {
switch self {
case .deferredToDate:
return Date.fromDatabaseValue(dbValue)
+8 -1
View File
@@ -113,7 +113,7 @@ public protocol FetchableRecord {
///
/// - throws: An error is thrown if the record can't be decoded from the
/// database row.
init(row: Row) throws
init(row: some RowProtocol) throws
// MARK: - Customizing the Format of Database Columns
@@ -260,6 +260,13 @@ extension FetchableRecord {
}
}
extension FetchableRecord {
#warning("TODO: document")
public init(row columnsWithValues: KeyValuePairs<String, (any DatabaseValueConvertible)?>) throws {
try self.init(row: Row(columnsWithValues: columnsWithValues))
}
}
extension FetchableRecord {
// MARK: Fetching From Prepared Statement
+2 -2
View File
@@ -41,8 +41,8 @@ open class Record {
public init() { }
/// Creates a Record from a row.
public required init(row: Row) throws {
if row.isFetched {
public required init(row: some RowProtocol) throws {
if row._isFetched {
// Take care of the hasDatabaseChanges flag.
//
// Row may be a reused row which will turn invalid as soon as the
+4
View File
@@ -326,6 +326,7 @@
56F89E1C2A585E0D002FE2AA /* SQLTableGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56F89E192A585E0D002FE2AA /* SQLTableGenerator.swift */; };
56FA0C3728B1F2EB00B2DFF7 /* MutablePersistableRecord+Upsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FA0C3428B1F2EB00B2DFF7 /* MutablePersistableRecord+Upsert.swift */; };
56FA0C4128B20ADB00B2DFF7 /* PersistableRecord+Upsert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FA0C4028B20ADB00B2DFF7 /* PersistableRecord+Upsert.swift */; };
56FA60322BB96ABF0085DEB7 /* RowProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FA60302BB96ABF0085DEB7 /* RowProtocol.swift */; };
56FBFED62210731100945324 /* SQLRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FBFED52210731000945324 /* SQLRequest.swift */; };
56FEB8FE248403270081AF83 /* DatabaseTraceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FEB8FC248403270081AF83 /* DatabaseTraceTests.swift */; };
56FEE7FE1F47253700D930EA /* TableRecordTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56FEE7FA1F47253700D930EA /* TableRecordTests.swift */; };
@@ -853,6 +854,7 @@
56F89E192A585E0D002FE2AA /* SQLTableGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLTableGenerator.swift; sourceTree = "<group>"; };
56FA0C3428B1F2EB00B2DFF7 /* MutablePersistableRecord+Upsert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MutablePersistableRecord+Upsert.swift"; sourceTree = "<group>"; };
56FA0C4028B20ADB00B2DFF7 /* PersistableRecord+Upsert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PersistableRecord+Upsert.swift"; sourceTree = "<group>"; };
56FA60302BB96ABF0085DEB7 /* RowProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowProtocol.swift; sourceTree = "<group>"; };
56FBFED52210731000945324 /* SQLRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SQLRequest.swift; sourceTree = "<group>"; };
56FDECE11BB32DFD009AD709 /* RowFromStatementTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFromStatementTests.swift; sourceTree = "<group>"; };
56FEB8FC248403270081AF83 /* DatabaseTraceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatabaseTraceTests.swift; sourceTree = "<group>"; };
@@ -1595,6 +1597,7 @@
56A238761B9C75030082EB20 /* Row.swift */,
567404871CEF84C8003ED5CC /* RowAdapter.swift */,
56231E6025CEBF06001DFD2F /* RowDecodingError.swift */,
56FA60302BB96ABF0085DEB7 /* RowProtocol.swift */,
56BB6EA81D3009B100A1CA52 /* SchedulingWatchdog.swift */,
560A37A61C8FF6E500949E71 /* SerializedDatabase.swift */,
56D3332129C38D7A00430680 /* WALSnapshotTransaction.swift */,
@@ -2088,6 +2091,7 @@
5659F48A1EA8D94E004A4992 /* Utils.swift in Sources */,
F3BA807F1CFB2E61003DC1BA /* NSString.swift in Sources */,
56F89DFA2A57EAB9002FE2AA /* ColumnDefinition.swift in Sources */,
56FA60322BB96ABF0085DEB7 /* RowProtocol.swift in Sources */,
56F89E1C2A585E0D002FE2AA /* SQLTableGenerator.swift in Sources */,
5603CEC52AC862F800CF097D /* SQLJSONExpressible.swift in Sources */,
560233D127243A9200529DF3 /* SharedValueObservation.swift in Sources */,
+8 -8
View File
@@ -1121,7 +1121,7 @@ struct Link: FetchableRecord {
var url: URL
var isVerified: Bool
init(row: Row) {
init(row: some RowProtocol) {
url = row["url"]
isVerified = row["verified"]
}
@@ -1876,7 +1876,7 @@ Details follow:
```swift
protocol FetchableRecord {
/// Row initializer
init(row: Row) throws
init(row: some RowProtocol) throws
}
```
@@ -1890,7 +1890,7 @@ struct Place {
}
extension Place : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
title = row["title"]
coordinate = CLLocationCoordinate2D(
@@ -1908,7 +1908,7 @@ extension Place : FetchableRecord {
case id, title, latitude, longitude
}
init(row: Row) {
init(row: some RowProtocol) {
id = row[Columns.id]
title = row[Columns.title]
coordinate = CLLocationCoordinate2D(
@@ -2839,7 +2839,7 @@ class Place: Record {
}
/// Creates a record from a database row
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row[Columns.id]
title = row[Columns.title]
isFavorite = row[Columns.favorite]
@@ -3210,7 +3210,7 @@ extension Place: TableRecord {
// Fetching methods
extension Place: FetchableRecord {
/// Creates a record from a database row
init(row: Row) {
init(row: some RowProtocol) {
id = row[Columns.id]
title = row[Columns.title]
isFavorite = row[Columns.isFavorite]
@@ -3291,7 +3291,7 @@ extension Place: TableRecord {
// Fetching methods
extension Place: FetchableRecord {
/// Creates a record from a database row
init(row: Row) {
init(row: some RowProtocol) {
// For high performance, use numeric indexes that match the
// order of Place.databaseSelection
id = row[0]
@@ -3343,7 +3343,7 @@ class Place: Record {
}
/// Creates a record from a database row
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row[Columns.id]
title = row[Columns.title]
isFavorite = row[Columns.isFavorite]
@@ -20,7 +20,7 @@ private struct PlayerWithRequiredTeam: FetchableRecord {
var player: Player
var team: Team
init(row: Row) throws {
init(row: some RowProtocol) throws {
player = try Player(row: row)
team = row[Player.teamScope]
}
@@ -30,7 +30,7 @@ private struct PlayerWithOptionalTeam: FetchableRecord {
var player: Player
var team: Team?
init(row: Row) throws {
init(row: some RowProtocol) throws {
player = try Player(row: row)
team = row[Player.teamScope]
}
@@ -40,7 +40,7 @@ private struct PlayerWithTeamName: FetchableRecord {
var player: Player
var teamName: String?
init(row: Row) throws {
init(row: some RowProtocol) throws {
player = try Player(row: row)
teamName = row["teamName"]
}
@@ -25,7 +25,7 @@ private struct AWithRequiredC: FetchableRecord {
var a: A
var c: C
init(row: Row) throws {
init(row: some RowProtocol) throws {
a = try A(row: row)
c = row["c"]
}
@@ -35,7 +35,7 @@ private struct AWithOptionalC: FetchableRecord {
var a: A
var c: C?
init(row: Row) throws {
init(row: some RowProtocol) throws {
a = try A(row: row)
c = row["c"]
}
@@ -46,7 +46,7 @@ private struct AWithRequiredBAndOptionalC: FetchableRecord {
var b: B
var c: C?
init(row: Row) throws {
init(row: some RowProtocol) throws {
a = try A(row: row)
b = row["b"]
c = row["c"]
@@ -57,7 +57,7 @@ private struct AWithCName: FetchableRecord {
var a: A
var cName: String?
init(row: Row) throws {
init(row: some RowProtocol) throws {
a = try A(row: row)
cName = row["cName"]
}
@@ -68,7 +68,7 @@ private struct AWithRequiredBNameAndOptionalCName: FetchableRecord {
var bName: String
var cName: String?
init(row: Row) throws {
init(row: some RowProtocol) throws {
a = try A(row: row)
bName = row["bName"]
cName = row["cName"]
@@ -5,7 +5,7 @@ private struct A: TableRecord, FetchableRecord, Equatable {
var cola1: Int64
var cola2: String
init(row: Row) {
init(row: some RowProtocol) {
cola1 = row["cola1"]
cola2 = row["cola2"]
}
@@ -15,7 +15,7 @@ private struct B: TableRecord, FetchableRecord, Hashable {
var colb2: Int64?
var colb3: String
init(row: Row) {
init(row: some RowProtocol) {
colb1 = row["colb1"]
colb2 = row["colb2"]
colb3 = row["colb3"]
@@ -25,7 +25,7 @@ private struct C: TableRecord, FetchableRecord, Equatable {
var colc1: Int64
var colc2: Int64
init(row: Row) {
init(row: some RowProtocol) {
colc1 = row["colc1"]
colc2 = row["colc2"]
}
@@ -35,7 +35,7 @@ private struct D: TableRecord, FetchableRecord, Equatable {
var cold2: Int64?
var cold3: String
init(row: Row) {
init(row: some RowProtocol) {
cold1 = row["cold1"]
cold2 = row["cold2"]
cold3 = row["cold3"]
@@ -123,7 +123,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.bs = bs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), bs: row["bs"])
}
}
@@ -131,7 +131,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
bs: [
@@ -152,7 +152,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
bs: [
B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
@@ -172,7 +172,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.bs = bs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), bs: row["bs"])
}
}
@@ -180,7 +180,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
bs: [
@@ -201,7 +201,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
bs: [
B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
@@ -238,7 +238,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.bs2 = bs2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), bs1: row["bs1"], bs2: row["bs2"])
}
}
@@ -246,7 +246,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
bs1: [
@@ -267,7 +267,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
bs1: [
B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
@@ -304,7 +304,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.ds = ds
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(c: C(row: row), ds: row["ds"])
}
}
@@ -316,7 +316,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs = cs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs: row["cs"])
}
}
@@ -324,7 +324,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: [
@@ -358,7 +358,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: [
Record.CInfo(
@@ -392,7 +392,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.ds = ds
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(c: C(row: row), ds: row["ds"])
}
}
@@ -404,7 +404,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs = cs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs: row["cs"])
}
}
@@ -412,7 +412,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: []),
@@ -428,7 +428,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: []))
}
@@ -482,7 +482,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.ds2 = ds2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(c: C(row: row), ds1: row["ds1"], ds2: row["ds2"])
}
}
@@ -496,7 +496,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs2 = cs2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs1: row["cs1"], cs2: row["cs2"])
}
}
@@ -504,7 +504,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs1: [],
@@ -550,7 +550,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs1: [],
cs2: [
@@ -590,7 +590,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.d = d
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(c: C(row: row), d: row["d"])
}
}
@@ -602,7 +602,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs = cs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs: row["cs"])
}
}
@@ -610,7 +610,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: [
@@ -640,7 +640,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: [
Record.CInfo(
@@ -672,7 +672,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.d = d
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(c: C(row: row), d: row["d"])
}
}
@@ -684,7 +684,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs = cs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs: row["cs"])
}
}
@@ -692,7 +692,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: []),
@@ -708,7 +708,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: []))
}
@@ -762,7 +762,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.d2 = d2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(c: C(row: row), d1: row["d1"], d2: row["d2"])
}
}
@@ -776,7 +776,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs2 = cs2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs1: row["cs1"], cs2: row["cs2"])
}
}
@@ -784,7 +784,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs1: [],
@@ -818,7 +818,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs1: [],
cs2: [
@@ -852,7 +852,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.ds = ds
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), ds: row["ds"])
}
}
@@ -860,7 +860,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
ds: [
@@ -882,7 +882,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
ds: [
D(row: ["cold1": 10, "cold2": 7, "cold3": "d1"]),
@@ -923,7 +923,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.ds3 = ds3
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), ds1: row["ds1"], ds2: row["ds2"], ds3: row["ds3"])
}
}
@@ -931,7 +931,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
ds1: [],
@@ -958,7 +958,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
a: A(row: ["cola1": 1, "cola2": "a1"]),
ds1: [],
ds2: [
@@ -996,7 +996,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs = cs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs: row["cs"])
}
}
@@ -1008,7 +1008,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.a = a
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(b: B(row: row), a: row["a"])
}
}
@@ -1016,7 +1016,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
b: B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
a: Record.AInfo(
@@ -1048,7 +1048,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
b: B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
a: Record.AInfo(
a: A(row: ["cola1": 1, "cola2": "a1"]),
@@ -1071,7 +1071,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs = cs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(b: B(row: row), a: row["a"], cs: row["cs"])
}
}
@@ -1079,7 +1079,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
b: B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
a: A(row: ["cola1": 1, "cola2": "a1"]),
@@ -1109,7 +1109,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
b: B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
a: A(row: ["cola1": 1, "cola2": "a1"]),
cs: [
@@ -1164,7 +1164,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.cs2 = cs2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(a: A(row: row), cs1: row["cs1"], cs2: row["cs2"])
}
}
@@ -1178,7 +1178,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.a2 = a2
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(b: B(row: row), a1: row["a1"], a2: row["a2"])
}
}
@@ -1186,7 +1186,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
b: B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
a1: Record.AInfo(
@@ -1226,7 +1226,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
b: B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
a1: Record.AInfo(
a: A(row: ["cola1": 1, "cola2": "a1"]),
@@ -1264,7 +1264,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
self.bs = bs
}
init(row: Row) {
init(row: some RowProtocol) {
self.init(d: D(row: row), bs: row["bs"])
}
}
@@ -1272,7 +1272,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchAll
do {
let records = try Record.fetchAll(db, request)
XCTAssertEqual(records, [
try XCTAssertEqual(records, [
Record(
d: D(row: ["cold1": 10, "cold2": 7, "cold3": "d1"]),
bs: [
@@ -1303,7 +1303,7 @@ class AssociationPrefetchingFetchableRecordTests: GRDBTestCase {
// Record.fetchOne
do {
let record = try Record.fetchOne(db, request)!
XCTAssertEqual(record, Record(
try XCTAssertEqual(record, Record(
d: D(row: ["cold1": 10, "cold2": 7, "cold3": "d1"]),
bs: [
B(row: ["colb1": 4, "colb2": 1, "colb3": "b1"]),
@@ -97,7 +97,7 @@ class AssociationRowScopeSearchTests: GRDBTestCase {
var b: B
var c: C
var d: D
init(row: Row) throws {
init(row: some RowProtocol) throws {
a = try A(row: row)
b = row["b"]
c = row["c"]
@@ -174,7 +174,7 @@ class AssociationRowScopeSearchTests: GRDBTestCase {
struct CustomA: FetchableRecord, Decodable {
var id: Int64
var custom: Bool?
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
custom = true
}
@@ -183,7 +183,7 @@ class AssociationRowScopeSearchTests: GRDBTestCase {
var id: Int64
var aid: Int64
var custom: Bool?
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
aid = row["aid"]
custom = true
@@ -194,7 +194,7 @@ class AssociationRowScopeSearchTests: GRDBTestCase {
var aid: Int64?
var bid: Int64?
var custom: Bool?
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
aid = row["aid"]
bid = row["bid"]
@@ -205,7 +205,7 @@ class AssociationRowScopeSearchTests: GRDBTestCase {
var id: Int64
var bid: Int64
var custom: Bool?
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
bid = row["bid"]
custom = true
+4 -4
View File
@@ -22,7 +22,7 @@ class ColumnExpressionTests: GRDBTestCase {
// Test databaseSelection
static let databaseSelection: [any SQLSelectable] = [Columns.id, Columns.name, Columns.score]
init(row: Row) {
init(row: some RowProtocol) {
// Test row subscript
id = row[Columns.id]
name = row[Columns.name]
@@ -58,7 +58,7 @@ class ColumnExpressionTests: GRDBTestCase {
try XCTAssertEqual(Player.filter([1, 2, 3].contains(Player.Columns.id)).databaseRegion(db).description, "player(id,name,score)[1,2,3]")
// Test specific column updates
let player = Player(row: ["id": 1, "name": "Arthur", "score": 1000])
let player = try Player(row: ["id": 1, "name": "Arthur", "score": 1000])
try? player.update(db, columns: [Player.Columns.name, Player.Columns.score])
XCTAssertEqual(lastSQLQuery, "UPDATE \"player\" SET \"name\"=\'Arthur\', \"score\"=1000 WHERE \"id\"=1")
@@ -82,7 +82,7 @@ class ColumnExpressionTests: GRDBTestCase {
// Test databaseSelection
static let databaseSelection: [any SQLSelectable] = [Columns.id, Columns.name, Columns.score]
init(row: Row) {
init(row: some RowProtocol) {
// Test row subscript
id = row[Columns.id]
name = row[Columns.name]
@@ -118,7 +118,7 @@ class ColumnExpressionTests: GRDBTestCase {
try XCTAssertEqual(Player.filter([1, 2, 3].contains(Player.Columns.id)).databaseRegion(db).description, "player(id,name,score)[1,2,3]")
// Test specific column updates
let player = Player(row: ["id": 1, "name": "Arthur", "score": 1000])
let player = try Player(row: ["id": 1, "name": "Arthur", "score": 1000])
try? player.update(db, columns: [Player.Columns.name, Player.Columns.score])
XCTAssertEqual(lastSQLQuery, "UPDATE \"player\" SET \"name\"=\'Arthur\', \"score\"=1000 WHERE \"id\"=1")
@@ -104,15 +104,15 @@ private class UserPersistableRecord2 : PersistableRecord {
// MARK: - FetchableRecord
private struct UserFetchableRecord1 : FetchableRecord {
init(row: Row) { }
init(row: some RowProtocol) { }
}
private class UserFetchableRecord2 : FetchableRecord {
required init(row: Row) { }
required init(row: some RowProtocol) { }
}
private struct UserFetchableRecord3 : FetchableRecord {
init(row: Row) throws { }
init(row: some RowProtocol) throws { }
}
// MARK: - StatementColumnConvertible
@@ -7,7 +7,7 @@ import GRDB
private class UserRecord : Record {
override init() { super.init() }
required init(row: Row) throws { try super.init(row: row) }
required init(row: some RowProtocol) throws { try super.init(row: row) }
override class var databaseTableName: String { super.databaseTableName }
override class var persistenceConflictPolicy: PersistenceConflictPolicy { super.persistenceConflictPolicy }
override class var databaseSelection: [any SQLSelectable] { super.databaseSelection }
+2 -2
View File
@@ -312,7 +312,7 @@ class DatabaseCursorTests: GRDBTestCase {
// Profiling test
func testRecordCursorStep() throws {
struct S: FetchableRecord { init(row: Row) { } }
struct S: FetchableRecord { init(row: some RowProtocol) { } }
let dbQueue = try makeDatabaseQueue()
try dbQueue.read { db in
let cursor: RecordCursor<S> = try S.fetchCursor(db, sql: profilingSQL)
@@ -322,7 +322,7 @@ class DatabaseCursorTests: GRDBTestCase {
// Profiling test
func testRecordCursorForEach() throws {
struct S: FetchableRecord { init(row: Row) { } }
struct S: FetchableRecord { init(row: some RowProtocol) { } }
let dbQueue = try makeDatabaseQueue()
try dbQueue.read { db in
let cursor: RecordCursor<S> = try S.fetchCursor(db, sql: profilingSQL)
@@ -6,7 +6,7 @@ class DatabaseValueConversionErrorTests: GRDBTestCase {
struct Record: FetchableRecord {
var name: String
init(row: Row) throws {
init(row: some RowProtocol) throws {
name = try row.decode(forKey: "name")
}
}
@@ -122,7 +122,7 @@ class DatabaseValueConversionErrorTests: GRDBTestCase {
struct Record: FetchableRecord {
var value: Value
init(row: Row) throws {
init(row: some RowProtocol) throws {
value = try row.decode(forKey: "value")
}
}
+1 -1
View File
@@ -9,7 +9,7 @@ private struct Book {
}
extension Book : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row[.rowID]
title = row["title"]
author = row["author"]
+1 -1
View File
@@ -9,7 +9,7 @@ private struct Book {
}
extension Book : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row[.rowID]
title = row["title"]
author = row["author"]
+1 -1
View File
@@ -10,7 +10,7 @@ private struct Book {
}
extension Book : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row[.rowID]
title = row["title"]
author = row["author"]
@@ -8,7 +8,7 @@ private struct Reader: Hashable {
}
extension Reader : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
name = row["name"]
age = row["age"]
@@ -36,7 +36,7 @@ private struct AltReader {
}
extension AltReader : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
id = row["id"]
name = row["name"]
age = row["age"]
@@ -39,17 +39,17 @@ extension FetchableRecordDecodableTests {
}
}
func testCustomFetchableRecord() {
func testCustomFetchableRecord() throws {
struct Struct : FetchableRecord, Decodable {
let value: String
init(row: Row) {
init(row: some RowProtocol) {
value = (row["value"] as String) + " (FetchableRecord)"
}
}
do {
let s = Struct(row: ["value": "foo"])
let s = try Struct(row: ["value": "foo"])
XCTAssertEqual(s.value, "foo (FetchableRecord)")
}
}
@@ -900,7 +900,7 @@ extension FetchableRecordDecodableTests {
"requiredDates": "[128000]",
"optionalDates": "[null, 128000]",
"optionalDates2": "[128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: "test1",
@@ -916,7 +916,7 @@ extension FetchableRecordDecodableTests {
"REQUIREDDATES": "[128000]",
"OPTIONALDATES": "[null, 128000]",
"OPTIONALDATES2": "[128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: "test1",
@@ -932,7 +932,7 @@ extension FetchableRecordDecodableTests {
"requiredDates": "[128000]",
"optionalDates": "[null, 128000]",
"optionalDates2": nil,
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: nil,
@@ -946,7 +946,7 @@ extension FetchableRecordDecodableTests {
"requiredId": 1,
"requiredDates": "[128000]",
"optionalDates": "[null, 128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: nil,
@@ -962,7 +962,7 @@ extension FetchableRecordDecodableTests {
"requiredDates": "[128000]",
"optionalDates": "[null, 128000]",
"optionalDates2": "[128000]",
])
] as Row)
XCTFail("Expected error")
} catch let RowDecodingError.keyNotFound(.columnName(column), context) {
XCTAssertEqual(column, "requiredId")
@@ -996,7 +996,7 @@ extension FetchableRecordDecodableTests {
"required_dates": "[128000]",
"optional_dates": "[null, 128000]",
"optional_dates2": "[128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: "test1",
@@ -1012,7 +1012,7 @@ extension FetchableRecordDecodableTests {
"REQUIRED_DATES": "[128000]",
"OPTIONAL_DATES": "[null, 128000]",
"OPTIONAL_DATES2": "[128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: "test1",
@@ -1028,7 +1028,7 @@ extension FetchableRecordDecodableTests {
"required_dates": "[128000]",
"optional_dates": "[null, 128000]",
"optional_dates2": nil,
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: nil,
@@ -1042,7 +1042,7 @@ extension FetchableRecordDecodableTests {
"required_id": 1,
"required_dates": "[128000]",
"optional_dates": "[null, 128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: nil,
@@ -1059,7 +1059,7 @@ extension FetchableRecordDecodableTests {
"requiredDates": "[128000]",
"optionalDates": "[null, 128000]",
"optionalDates2": "[128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: "test1",
@@ -1075,7 +1075,7 @@ extension FetchableRecordDecodableTests {
"required_dates": "[128000]",
"optional_dates": "[null, 128000]",
"optional_dates2": "[128000]",
])
] as Row)
XCTFail("Expected error")
} catch let RowDecodingError.keyNotFound(.columnName(column), context) {
XCTAssertEqual(column, "requiredId")
@@ -1092,7 +1092,7 @@ extension FetchableRecordDecodableTests {
"required_dates": "[128000]",
"optional_dates": "[null, 128000]",
"optional_dates2": "[128000]",
])
] as Row)
XCTFail("Expected error")
} catch let RowDecodingError.keyNotFound(.columnName(column), context) {
XCTAssertEqual(column, "requiredID")
@@ -1130,7 +1130,7 @@ extension FetchableRecordDecodableTests {
"_requiredDates": "[128000]",
"_optionalDates": "[null, 128000]",
"_optionalDates2": "[128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: "test1",
@@ -1146,7 +1146,7 @@ extension FetchableRecordDecodableTests {
"_requiredDates": "[128000]",
"_optionalDates": "[null, 128000]",
"_optionalDates2": nil,
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: nil,
@@ -1160,7 +1160,7 @@ extension FetchableRecordDecodableTests {
"_requiredId": 1,
"_requiredDates": "[128000]",
"_optionalDates": "[null, 128000]",
])
] as Row)
XCTAssertEqual(record, Record(
requiredId: 1,
optionalName: nil,
@@ -1176,7 +1176,7 @@ extension FetchableRecordDecodableTests {
"_requiredDates": "[128000]",
"_optionalDates": "[null, 128000]",
"_optionalDates2": "[128000]",
])
] as Row)
XCTFail("Expected error")
} catch let RowDecodingError.keyNotFound(.columnName(column), context) {
XCTAssertEqual(column, "requiredId")
@@ -1493,7 +1493,7 @@ extension FetchableRecordDecodableTests {
// all optionals decode missing keys are nil. This is because GRDB
// records accept rows with missing columns, and b and c may want to
// decode columns.
_ = try FetchableRecordDecoder().decode(Composed.self, from: [:])
_ = try FetchableRecordDecoder().decode(Composed.self, from: Row())
}
// This is a regression test for https://github.com/groue/GRDB.swift/issues/664
@@ -1505,7 +1505,7 @@ extension FetchableRecordDecodableTests {
var b: B
}
do {
_ = try FetchableRecordDecoder().decode(Composed.self, from: [:])
_ = try FetchableRecordDecoder().decode(Composed.self, from: Row())
XCTFail("Expected error")
} catch DecodingError.keyNotFound {
// a or b can not be decoded because only one key is allowed to be missing
@@ -1631,7 +1631,7 @@ extension FetchableRecordDecodableTests {
self.isFetched = false
}
init(row: Row) throws {
init(row: some RowProtocol) throws {
self = try FetchableRecordDecoder().decode(Player.self, from: row)
self.isFetched = true
}
+1 -1
View File
@@ -7,7 +7,7 @@ private struct Fetched: Hashable{
}
extension Fetched : FetchableRecord {
init(row: Row) {
init(row: some RowProtocol) {
firstName = row["firstName"]
lastName = row["lastName"]
}
+1 -1
View File
@@ -181,7 +181,7 @@ class GRDBTestCase: XCTestCase {
line: UInt = #line)
throws
{
let request: SQLRequest<Row> = "SELECT \(expression)"
let request = SQLRequest(literal: "SELECT \(expression)")
try assertEqualSQL(db, request, "SELECT \(sql)", file: file, line: line)
}
+1 -1
View File
@@ -84,7 +84,7 @@ private struct FlatModel: FetchableRecord {
var t3: T3?
var t5count: Int
init(row: Row) {
init(row: some RowProtocol) {
self.t1 = row[Scopes.t1]
self.t2Left = row[Scopes.t2Left]
self.t2Right = row[Scopes.t2Right]
@@ -288,7 +288,7 @@ class MutablePersistableRecordChangesTests: GRDBTestCase {
case id, firstName, lastName
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row[Columns.id]
firstName = row[Columns.firstName]
lastName = row[Columns.lastName]
@@ -13,7 +13,7 @@ private class Reader : Record {
super.init()
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
self.id = row["id"]
self.name = row["name"]
self.age = row["age"]
+3 -3
View File
@@ -31,7 +31,7 @@ private class Person : Record {
"persons"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row["id"]
age = row["age"]
name = row["name"]
@@ -69,7 +69,7 @@ private class IntegerPropertyOnRealAffinityColumn : Record {
// Record
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
value = row["value"]
try super.init(row: row)
}
@@ -99,7 +99,7 @@ private class PersonWithModifiedCaseColumns: Record {
"persons"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row["ID"]
age = row["AGE"]
name = row["NAME"]
@@ -15,11 +15,11 @@ class EmptyRecordWithoutInitializer : Record {
// let name: String?
// }
// What happens with a mutable property, and init(row: Row)?
// What happens with a mutable property, and init(row: some RowProtocol)?
class RecordWithMutablePropertyAndRowInitializer : Record {
var name: String?
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
try super.init(row: row) // super.init(row: row) is required
self.name = "toto" // property can be set before or after super.init
}
@@ -34,7 +34,7 @@ class RecordWithMutablePropertyAndEmptyInitializer : Record {
self.name = "toto" // property can be set before or after super.init
}
required init(row: Row) throws { // init(row) is required
required init(row: some RowProtocol) throws { // init(row) is required
try super.init(row: row) // super.init(row: row) is required
}
}
@@ -48,7 +48,7 @@ class RecordWithMutablePropertyAndCustomInitializer : Record {
super.init() // super.init() is required
}
required init(row: Row) throws { // init(row) is required
required init(row: some RowProtocol) throws { // init(row) is required
try super.init(row: row) // super.init(row: row) is required
}
}
@@ -57,7 +57,7 @@ class RecordWithMutablePropertyAndCustomInitializer : Record {
class RecordWithImmutableProperty : Record {
let initializedFromRow: Bool
required init(row: Row) throws { // An initializer is required, and the minimum is init(row)
required init(row: some RowProtocol) throws { // An initializer is required, and the minimum is init(row)
initializedFromRow = true // property must be set before super.init(row: row)
try super.init(row: row) // super.init(row: row) is required
}
@@ -72,7 +72,7 @@ class RecordWithPedigree : Record {
super.init() // super.init() is required
}
required init(row: Row) throws { // An initializer is required, and the minimum is init(row)
required init(row: some RowProtocol) throws { // An initializer is required, and the minimum is init(row)
initializedFromRow = true // property must be set before super.init(row: row)
try super.init(row: row) // super.init(row: row) is required
}
@@ -87,7 +87,7 @@ class RecordWithImmutablePropertyAndCustomInitializer : Record {
super.init() // super.init() is required
}
required init(row: Row) throws { // An initializer is required, and the minimum is init(row)
required init(row: some RowProtocol) throws { // An initializer is required, and the minimum is init(row)
initializedFromRow = true // property must be set before super.init(row: row)
try super.init(row: row) // super.init(row: row) is required
}
@@ -97,7 +97,7 @@ class RecordInitializersTests : GRDBTestCase {
func testFetchedRecordAreInitializedFromRow() throws {
// Here we test that Record.init(row: Row) can be overridden independently from Record.init().
// Here we test that Record.init(row: row) can be overridden independently from Record.init().
// People must be able to perform some initialization work when fetching records from the database.
XCTAssertFalse(RecordWithPedigree().initializedFromRow)
@@ -23,7 +23,7 @@ private class MinimalNonOptionalPrimaryKeySingle: Record, Hashable {
"minimalSingles"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row["id"]
try super.init(row: row)
}
@@ -22,7 +22,7 @@ class MinimalRowID : Record, Hashable {
"minimalRowIDs"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row["id"]
try super.init(row: row)
}
@@ -21,7 +21,7 @@ class MinimalSingle: Record, Hashable {
"minimalSingles"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
UUID = row["UUID"]
try super.init(row: row)
}
@@ -35,7 +35,7 @@ private class Person : Record, Hashable {
"persons"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row[.rowID]
age = row["age"]
name = row["name"]
@@ -30,7 +30,7 @@ private class Citizenship : Record, Hashable {
"citizenships"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
personName = row["personName"]
countryName = row["countryName"]
native = row["native"]
@@ -28,7 +28,7 @@ private class Item : Record, Hashable {
"items"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
name = row["name"]
email = row["email"]
try super.init(row: row)
@@ -32,7 +32,7 @@ private class Person : Record, Hashable {
"persons"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row["id"]
age = row["age"]
name = row["name"]
@@ -26,7 +26,7 @@ class Pet : Record, Hashable {
"pets"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
UUID = row["UUID"]
name = row["name"]
try super.init(row: row)
@@ -25,7 +25,7 @@ class Email : Record, Hashable {
"emails"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
email = row["email"]
label = row["label"]
try super.init(row: row)
+3 -3
View File
@@ -31,7 +31,7 @@ private class Person : Record {
"persons"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
id = row["id"]
age = row["age"]
name = row["name"]
@@ -64,7 +64,7 @@ private class MinimalPersonWithOverrides : Person {
// Record
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
extra = row["extra"]
try super.init(row: row)
}
@@ -85,7 +85,7 @@ private class PersonWithOverrides : Person {
// Record
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
extra = row["extra"]
try super.init(row: row)
}
+1 -1
View File
@@ -3,7 +3,7 @@ import XCTest
private struct Person : FetchableRecord, TableRecord {
static let databaseTableName = "persons"
init(row: Row) {
init(row: some RowProtocol) {
}
}
@@ -23,7 +23,7 @@ class BadlyMangledStuff : Record {
"stuffs"
}
required init(row: Row) throws {
required init(row: some RowProtocol) throws {
// Here user may peek fancy column names that match his SQL queries.
// However this is not the way to do it (see testBadlyMangledStuff()).
id = row["mangled_id"]
+4 -4
View File
@@ -439,7 +439,7 @@ class TableRecordDeleteTests: GRDBTestCase {
struct Player: MutablePersistableRecord, FetchableRecord {
static let team = belongsTo(Team.self)
func encode(to container: inout PersistenceContainer) { preconditionFailure("should not be called") }
init(row: Row) { preconditionFailure("should not be called") }
init(row: some RowProtocol) { preconditionFailure("should not be called") }
}
struct Team: MutablePersistableRecord, FetchableRecord {
@@ -447,7 +447,7 @@ class TableRecordDeleteTests: GRDBTestCase {
static let databaseSelection: [any SQLSelectable] = [Column("id"), Column("name")]
static let players = hasMany(Player.self)
func encode(to container: inout PersistenceContainer) { preconditionFailure("should not be called") }
init(row: Row) { preconditionFailure("should not be called") }
init(row: some RowProtocol) { preconditionFailure("should not be called") }
}
try db.create(table: "team") { t in
@@ -605,11 +605,11 @@ class TableRecordDeleteTests: GRDBTestCase {
try makeDatabaseQueue().inDatabase { db in
struct Player: MutablePersistableRecord, FetchableRecord {
func encode(to container: inout PersistenceContainer) { preconditionFailure("should not be called") }
init(row: Row) { preconditionFailure("should not be called") }
init(row: some RowProtocol) { preconditionFailure("should not be called") }
}
struct Passport: MutablePersistableRecord, FetchableRecord {
func encode(to container: inout PersistenceContainer) { preconditionFailure("should not be called") }
init(row: Row) { preconditionFailure("should not be called") }
init(row: some RowProtocol) { preconditionFailure("should not be called") }
}
try db.create(table: "player") { t in
t.autoIncrementedPrimaryKey("id")
@@ -8,7 +8,7 @@ private struct Player: Equatable {
extension Player: TableRecord, FetchableRecord {
static let databaseTableName = "t"
init(row: Row) {
init(row: some RowProtocol) {
self.init(id: row["id"], name: row["name"])
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ class ValueObservationTests: GRDBTestCase {
}
// Test that view v is included in the request region
let request = SQLRequest<Row>(sql: "SELECT name FROM v ORDER BY id")
let request = SQLRequest(sql: "SELECT name FROM v ORDER BY id")
try dbQueue.inDatabase { db in
let region = try request.databaseRegion(db)
XCTAssertEqual(region.description, "t(id,name),v(id,name)")
@@ -16,7 +16,7 @@ private struct Item: Codable, FetchableRecord, PersistableRecord {
var i8: Int
var i9: Int
init(row: Row) {
init(row: some RowProtocol) {
i0 = row[0]
i1 = row[1]
i2 = row[2]
@@ -41,7 +41,7 @@ class InsertRecordClassTests: XCTestCase {
super.init()
}
required init(row: Row) {
required init(row: some RowProtocol) {
fatalError("init(row:) has not been implemented")
}