Gwendal Roué committed 2022-08-21 21:22:34 +02:00
1 parent 42987dd849
commit 11a6d53d8a
11 files changed
+19 -19

No files matched your search

+3 -3
View File
@@ -322,7 +322,7 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
let authorizerP = Unmanaged.passUnretained(authorizer).toOpaque()
sqlite3_set_authorizer(
sqliteConnection,
{ (authorizerP, actionCode, cString1, cString2, cString3, cString4) -> Int32 in
{ (authorizerP, actionCode, cString1, cString2, cString3, cString4) in
Unmanaged<StatementAuthorizer>
.fromOpaque(authorizerP.unsafelyUnwrapped)
.takeUnretainedValue()
@@ -503,9 +503,9 @@ public final class Database: CustomStringConvertible, CustomDebugStringConvertib
collation.name,
SQLITE_UTF8,
collationPointer,
{ (collationPointer, length1, buffer1, length2, buffer2) -> Int32 in
{ (collationPointer, length1, buffer1, length2, buffer2) in
let collation = Unmanaged<DatabaseCollation>.fromOpaque(collationPointer!).takeUnretainedValue()
return Int32(collation.function(length1, buffer1, length2, buffer2).rawValue)
return CInt(collation.function(length1, buffer1, length2, buffer2).rawValue)
}, nil)
guard code == SQLITE_OK else {
// Assume a GRDB bug: there is no point throwing any error.
+1 -1
View File
@@ -925,7 +925,7 @@ extension StatementArguments {
/// :nodoc:
public var description: String {
let valuesDescriptions = values.map(\.description)
let namedValuesDescriptions = namedValues.map { (key, value) -> String in
let namedValuesDescriptions = namedValues.map { (key, value) in
"\(String(reflecting: key)): \(value)"
}
return "[" + (namedValuesDescriptions + valuesDescriptions).joined(separator: ", ") + "]"
+4 -4
View File
@@ -1234,7 +1234,7 @@ private struct MetalDatabasePreUpdateEventImpl: DatabasePreUpdateEventImpl {
return getValue(
connection,
column: CInt(index),
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) -> CInt in
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) in
sqlite3_preupdate_old(connection, column, &value)
})
}
@@ -1244,7 +1244,7 @@ private struct MetalDatabasePreUpdateEventImpl: DatabasePreUpdateEventImpl {
return getValue(
connection,
column: CInt(index),
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) -> CInt in
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) in
sqlite3_preupdate_new(connection, column, &value)
})
}
@@ -1298,7 +1298,7 @@ private struct MetalDatabasePreUpdateEventImpl: DatabasePreUpdateEventImpl {
private func preupdate_getValues_old(_ connection: SQLiteConnection) -> [DatabaseValue]? {
preupdate_getValues(
connection,
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) -> CInt in
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) in
sqlite3_preupdate_old(connection, column, &value)
})
}
@@ -1306,7 +1306,7 @@ private struct MetalDatabasePreUpdateEventImpl: DatabasePreUpdateEventImpl {
private func preupdate_getValues_new(_ connection: SQLiteConnection) -> [DatabaseValue]? {
preupdate_getValues(
connection,
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) -> CInt in
sqlite_func: { (connection: SQLiteConnection, column: CInt, value: inout SQLiteValue? ) in
sqlite3_preupdate_new(connection, column, &value)
})
}
+1 -1
View File
@@ -35,7 +35,7 @@ final class WALSnapshot {
/// error occurs.
init?(_ db: Database) {
var snapshot: UnsafeMutablePointer<sqlite3_snapshot>?
let code: CInt = withUnsafeMutablePointer(to: &snapshot) {
let code = withUnsafeMutablePointer(to: &snapshot) {
return sqlite3_snapshot_get(db.sqliteConnection, "main", $0)
}
guard code == SQLITE_OK, let snapshot else {
+1 -1
View File
@@ -127,7 +127,7 @@ extension FTS5Tokenizer {
tokenization: tokenization,
pText: pText,
nText: nText,
tokenCallback: { (contextPointer, flags, pToken, nToken, _ /* iStart */, _ /* iEnd */) -> Int32 in
tokenCallback: { (contextPointer, flags, pToken, nToken, _ /* iStart */, _ /* iEnd */) in
guard let contextPointer else {
return SQLITE_ERROR
}
+1 -1
View File
@@ -389,7 +389,7 @@ public struct DatabaseMigrator {
// Let's migrate a temporary database up to the same
// level, and compare the database schemas. If they
// differ, we'll erase the database.
let tmpSchema: SchemaInfo = try {
let tmpSchema = try {
// Make sure the temporary database is configured
// just as the migrated database
var tmpConfig = db.configuration
@@ -830,7 +830,7 @@ extension Array where Element == Row {
extension Row {
/// - precondition: Columns all exist in the row.
fileprivate func indexes(forColumns columns: [String]) -> [Int] {
columns.map { column -> Int in
columns.map { column in
guard let index = index(forColumn: column) else {
fatalError("Column \(column) is not selected")
}
+1 -1
View File
@@ -120,7 +120,7 @@ public struct _SQLAssociation {
// via: Pivot.belongsTo(Destination.self))
// Origin(id: 1).request(for: association)
let reversedSteps = zip(steps, steps.dropFirst())
.map { (step, nextStep) -> SQLAssociationStep in
.map { (step, nextStep) in
// Intermediate steps are not selected, and including(all:)
// children are useless:
let relation = step.relation
+1 -1
View File
@@ -893,7 +893,7 @@ extension JoinMapping {
fatalError("Provide at least one left row, or this method can't generate SQL that can be observed.")
}
let mappings: [(leftIndex: Rows.Element.ColumnIndex, rightColumn: Column)] = map { mapping in
let mappings = map { mapping in
guard let leftIndex = firstLeftRow.index(forColumn: mapping.left) else {
fatalError("Missing column: \(mapping.left)")
}
@@ -279,7 +279,7 @@ extension ValueConcurrentObserver {
}
// Reduce
let initialValue: Reducer.Value = reduceQueue.sync {
let initialValue = reduceQueue.sync {
guard let initialValue = reducer._value(fetchedValue) else {
fatalError("Broken contract: reducer has no initial value")
}
@@ -390,7 +390,7 @@ extension ValueConcurrentObserver {
// database versions. It prevents database checkpointing,
// and keeps WAL snapshots (`sqlite3_snapshot`) valid
// and comparable.
let isModified: Bool = withExtendedLifetime(initialSnapshot) {
let isModified = withExtendedLifetime(initialSnapshot) {
guard let initialWALSnapshot,
let currentWALSnapshot = WALSnapshot(writerDB)
else {
@@ -608,7 +608,7 @@ extension ValueConcurrentObserver: DatabaseCancellable {
func notifyError(_ error: Error) {
scheduler.schedule {
let events: ValueObservationEvents? = self.lock.synchronized {
let events = self.lock.synchronized {
let events = self.notificationCallbacks?.events
self.notificationCallbacks = nil
return events
@@ -413,7 +413,7 @@ extension ValueWriteOnlyObserver: TransactionObserver {
extension ValueWriteOnlyObserver: DatabaseCancellable {
func cancel() {
// Notify cancellation
let (events, writer): (ValueObservationEvents?, Writer?) = lock.synchronized {
let (events, writer) = lock.synchronized {
let events = notificationCallbacks?.events
notificationCallbacks = nil
return (events, databaseAccess?.writer)
@@ -433,7 +433,7 @@ extension ValueWriteOnlyObserver: DatabaseCancellable {
func notifyError(_ error: Error) {
scheduler.schedule {
let events: ValueObservationEvents? = self.lock.synchronized {
let events = self.lock.synchronized {
let events = self.notificationCallbacks?.events
self.notificationCallbacks = nil
return events