     public func databaseWillCommit() throws { }
     public func databaseDidRollback(db: Database) { }
     public func databaseDidCommit(db: Database) {
-        let newRecords = T.fetchAll(db, self.sql)
+        let newResults = T.fetchAll(db, self.sql)
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
-            let oldRecords = self.fetchedResults
+            let oldResults = self.fetchedResults
             
             // horrible diff computation
             dispatch_async(dispatch_get_main_queue()) {
                 self.delegate?.controllerWillUpdate(self)
                 
                 // after controllerWillChangeContent
-                self.fetchedResults = newRecords
+                self.fetchedResults = newResults
                 
                 // notify horrible diff computation
-                for update in self.diff(fromRows: oldRecords!, toRows: newRecords) {
+                for update in FetchedResultsController.diff(fromRows: oldResults!, toRows: newResults) {
                     self.delegate?.controllerUpdate(self, update: update)
                 }
                 

//  Created by Pascal Edmond on 09/12/2015.
//  Copyright © 2015 Gwendal Roué. All rights reserved.
//

public typealias FetchedResult = protocol<RowConvertible, DatabaseTableMapping, Equatable>


    public var description: String {
        switch self {
        case .Insertion(let item, let at):
            return "INSERTED \(item) AT index \(at.row)"
            
        case .Deletion(let item, let at):
            return "DELETED \(item) FROM index \(at.row)"
            
        case .Move(let item, let from, let to):
            return "MOVED \(item) FROM index \(from.row) TO index \(to.row)"
            
        case .Update(let item, let at, let changes):
            return "UPDATES \(changes) OF \(item) AT index \(at.row)"
        }
    }
}

public func ==<T>(lhs: Change<T>, rhs: Change<T>) -> Bool {
    switch (lhs, rhs) {
    case (.Insertion(let lhsResult, let lhsIndexPath), .Insertion(let rhsResult, let rhsIndexPath)) where lhsResult == rhsResult && lhsIndexPath == rhsIndexPath : return true
    case (.Deletion(let lhsResult, let lhsIndexPath), .Deletion(let rhsResult, let rhsIndexPath)) where lhsResult == rhsResult && lhsIndexPath == rhsIndexPath : return true
