     /// Returns a boolean indicating whether this record and the other record
     /// have the same database representation.
     public func databaseEquals(_ record: Self) -> Bool {
-        return databaseChangesIterator(from: record).next() == nil
+        return databaseChangesIterator(from: PersistenceContainer(record)).next() == nil
     }
 
     /// A dictionary of values changed from the other record.

        try update(db, columns: Set(columns.map { $0.name }))
    }
    
    /// If the record has differences from the other record, executes an UPDATE
    /// statement so that those changes and only those changes are saved in
    /// the database.
    ///
    /// This method is guaranteed to have saved the eventual changes in the
    /// database if it returns without error.
    ///
    /// - parameter db: A database connection.
    /// - parameter columns: The columns to update.
    /// - returns: Whether the record had changes.
    /// - throws: A DatabaseError is thrown whenever an SQLite error occurs.
    ///   PersistenceError.recordNotFound is thrown if the primary key does not
    ///   match any row in the database and record could not be updated.
    @discardableResult
    public func updateChanges(_ db: Database, from record: MutablePersistableRecord) throws -> Bool {
        let changedColumns = Set(databaseChanges(from: record).keys)
        if changedColumns.isEmpty {
            return false
        } else {

    /// same set of columns in their `encode(to:)` method, only the columns
    /// defined by the receiver record are considered.
    public func databaseChanges(from record: MutablePersistableRecord) -> [String: DatabaseValue] {
        return Dictionary(uniqueKeysWithValues: databaseChangesIterator(from: PersistenceContainer(record)))
    }
    
    fileprivate func databaseChangesIterator(from oldContainer: PersistenceContainer) -> AnyIterator<(String, DatabaseValue)> {
        var newValueIterator = PersistenceContainer(self).makeIterator()
        return AnyIterator {
            // Loop until we find a change, or exhaust columns:
