         }
         
         
-        // Extract primary key
-        
-        guard let primaryKeyDictionary = self.dynamicType.primaryKeyDictionary(databaseDictionary) else {
+        // Extract strong primary key
+        
+        let version = Version(self)
+        guard let primaryKeyDictionary = version.strongPrimaryKeyDictionary else {
             fatalError("No primaryKey")
         }
         

        }
        
        
        // Extract primary key
        
        guard let primaryKeyDictionary = self.dynamicType.primaryKeyDictionary(databaseDictionary) else {
            fatalError("No primaryKey")
        }
        

    }
    
    // MARK: - Not public
    
    private class Version {
        let rowModel: RowModel
        
        lazy var databasePrimaryKey: PrimaryKey = self.rowModel.dynamicType.databasePrimaryKey
        lazy var databaseDictionary: [String: SQLiteValueConvertible?] = self.rowModel.databaseDictionary
        
        // A primary key dictionary. Its values may be nil.
        lazy var weakPrimaryKeyDictionary: [String: SQLiteValueConvertible?]? = {
            switch self.databasePrimaryKey {
            case .None:
                return nil
                
            case .RowID(let column):
                let databaseDictionary = self.databaseDictionary
                if let value = databaseDictionary[column] {
                    return [column: value]
                } else {
                    return nil
                }
                
            case .Column(let column):
                let databaseDictionary = self.databaseDictionary
                if let value = databaseDictionary[column] {
                    return [column: value]
                } else {
                    return nil
                }
                
            case .Columns(let columns):
                let databaseDictionary = self.databaseDictionary
                var primaryKeyDictionary = [String: SQLiteValueConvertible?]()
                for column in columns {
                    if let value = databaseDictionary[column] {
                        primaryKeyDictionary[column] = value
                    } else {
                        primaryKeyDictionary[column] = nil
                    }
                }
                return primaryKeyDictionary
            }
        }()
        
        // A primary key dictionary. At least one of its values is not nil.
        lazy var strongPrimaryKeyDictionary: [String: SQLiteValueConvertible?]? = {
            guard let dictionary = self.weakPrimaryKeyDictionary else {
                return nil
            }
            for case let value? in dictionary.values {
                return dictionary // At least one non-nil value in the primary key dictionary is OK.
            }
            return nil
        }()
        
        func updateRowModelWithInsertionChanges(changes: UpdateStatement.Changes) {
            switch databasePrimaryKey {
            case .RowID(let column):
                if let optionalValue = databaseDictionary[column] {
                    if optionalValue == nil {
                        let row = Row(sqliteDictionary: [column: SQLiteValue.Integer(changes.insertedRowID!)])
                        rowModel.updateFromDatabaseRow(row)
                    }
                } else {
                    fatalError("databaseDictionary must return the value for the primary key `(column)`")
                }
            default:
                return
            }
        }
        
        init(_ rowModel: RowModel) {
            self.rowModel = rowModel
        }
    }
    
    // Attempts to build a primary key dictionary [String: SQLiteValueConvertible?].
    //
