From a3a0fa39f7f031b5f449274d1fd07fd13b72d441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Fri, 10 Jul 2015 09:09:54 +0200 Subject: [PATCH] RowModel.setDirty() --- GRDB/RowModel.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/GRDB/RowModel.swift b/GRDB/RowModel.swift index 911c6d941..b6d7393d5 100644 --- a/GRDB/RowModel.swift +++ b/GRDB/RowModel.swift @@ -113,11 +113,11 @@ public class RowModel { } // Primary key may have been updated: set dirty. - cleanRow = nil + setDirty() } - /// MARK: - Dirty + // MARK: - Dirty /// Return false if the stored database dictionary is known to be not been /// modified since last synchronization with the database (save or reload). @@ -130,7 +130,15 @@ public class RowModel { return cleanRow.containsSameColumnsAndValuesAsRow(Row(dictionary: storedDatabaseDictionary)) } + /// Forces the dirty flag + public func setDirty() { + cleanRow = nil + } + /// Reference row for isDirty. + private var cleanRow: Row? + + // MARK: - CRUD /// An enum that specifies an alternative constraint conflict resolution @@ -195,7 +203,7 @@ public class RowModel { // Future calls to update and save MUST throw RowModelNotFound. // A way to achieve this is to set rowModel dirty. - cleanRow = nil + setDirty() } /// Throws an error if the model has no table name, or no primary key. @@ -213,9 +221,6 @@ public class RowModel { } } - /// Reference row for isDirty. - private var cleanRow: Row? - // MARK: - Version