             if not before.equals(record)
                 # there was an actual change, so update; doesn't change anything involving indexes.
                 changes = changes.add(@_primary_key_cols(record))
-                return new DBDoc(@_primary_keys, @_string_cols, @_records.set(n, record), @_everything, @_indexes, changes)
+                return new DBDoc(@_primary_keys, @_string_cols, @_records.set(n, record), @_everything, @_indexes, {changes:changes, from_db:@_changes.from_db})
             else
                 return @
         else

            i += 2
        return db



class Doc
    constructor: (@_db) ->

        @_check()
        @_doc.set_doc(@_doc.undo())
        @_doc.save()
        @_on_change()
        return

    redo: =>
        @_check()
        @_doc.set_doc(@_doc.redo())
        @_doc.save()
        @_on_change()
        return

    exit_undo_mode: =>
