                 // Setup a new transaction observer. Use
                 // database.write, so that the transaction observer is added on the
                 // same serialized queue as transaction callbacks.
-                writer.write { db in
+                databaseWriter.write { db in
                     let statement = try! self.source.selectStatement(db)
                     let observer = FetchedRecordsObserver(
                         controller: self,

        // Fetch items on the writing dispatch queue, so that the transaction
        // observer is added on the same serialized queue as transaction
        // callbacks.
        writer.write { db in
            let statement = try! self.source.selectStatement(db)
            let items = Item<Record>.fetchAll(statement)
            self.fetchedItems = items

    ///
    ///     - compareRecordsByPrimaryKey: A boolean that tells if two records
    ///         share the same identity if they share the same primay key.
    public convenience init<U>(_ databaseWriter: DatabaseWriter, request: FetchRequest<U>, queue: dispatch_queue_t = dispatch_get_main_queue(), compareRecordsByPrimaryKey: Bool) {
        // Retype the fetch request
        let request: FetchRequest<Record> = FetchRequest(query: request.query)
        let source = DatabaseSource.FetchRequest(request)
        if compareRecordsByPrimaryKey {
            self.init(databaseWriter: databaseWriter, source: source, queue: queue, isSameRecordBuilder: { db in try! Record.primaryKeyComparator(db) })
        } else {
            self.init(databaseWriter: databaseWriter, source: source, queue: queue, isSameRecordBuilder: { _ in { _ in false } })
        }
    }
}
