GRDB.swift v2.6.0 Release Notes

  • ๐Ÿš€ Released January 18, 2018 • diff

    ๐Ÿ†• New

    • Database observation has been enhanced:

      • TransactionObserver.stopObservingDatabaseChangesUntilNextTransaction() allows transaction observers to stop observing the database for the remaining extent of a transaction.
      • GRDB no longer prevents the truncate optimization when no transaction observers are interested in deleted rows.
      • FetchedRecordsController now avoids checking for changes in untracked rowIds.
      • DatabaseRegion is a new public type that helps transaction observers recognize impactful database changes. This type is not documented in the main documentation. For more information, see DatabaseRegion reference, and look at FetchedRecordsController implementation.
      • TransactionObserver protocol provides default implementations for rarely used callbacks.
    • Row adopts RandomAccessCollection

    API diff

     extension TransactionObserver {
    +    func stopObservingDatabaseChangesUntilNextTransaction()
    +
    +    // Default implementation
    +    func databaseWillCommit() throws
    +
    +    #if SQLITE_ENABLE_PREUPDATE_HOOK
    +    // Default implementation
    +    func databaseWillChange(with event: DatabasePreUpdateEvent)
    +    #endif
     }
    
    +struct DatabaseRegion: Equatable {
    +    var isEmpty: Bool
    +
    +    init()
    +
    +    func union(_ other: DatabaseRegion) -> DatabaseRegion
    +    mutating func formUnion(_ other: DatabaseRegion)
    +
    +    func isModified(byEventsOfKind eventKind: DatabaseEventKind) -> Bool
    +    func isModified(by event: DatabaseEvent) -> Bool
    +}
    
     class SelectStatement {
    +    var fetchedRegion: DatabaseRegion
    +
    +    @available(*, deprecated, renamed:"DatabaseRegion")
    +    typealias SelectionInfo = DatabaseRegion
    +    
    +    @available(*, deprecated, renamed:"fetchedRegion")
    +    var selectionInfo: DatabaseRegion
     }
    
     enum DatabaseEventKind {
    -    func impacts(_ selectionInfo: SelectStatement.SelectionInfo) -> Bool
    +    @available(*, deprecated, message: "Use DatabaseRegion.isModified(byEventsOfKind:) instead")
    +    func impacts(_ region: DatabaseRegion) -> Bool
     }
    
     protocol Request {
    +    // Default implementation
    +    func fetchedRegion(_ db: Database) throws -> DatabaseRegion
     }
    
    +extension Row: RandomAccessCollection {
    +}
    +extension RowIndex: Strideable {
    }