diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c561f469..b3b9f0108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ Release Notes ============= -## Next Release +## Next Version **New** +- `Row` adopts the Hashable protocol - [FetchedRecordsController](https://github.com/groue/GRDB.swift#fetchedrecordscontroller) now outputs detailed change events on all platforms, and for both table and collection views. Merged [#160](https://github.com/groue/GRDB.swift/pull/160) by [@kdubb](https://github.com/kdubb). diff --git a/GRDB/Core/Row.swift b/GRDB/Core/Row.swift index 5089249fc..ae2704816 100644 --- a/GRDB/Core/Row.swift +++ b/GRDB/Core/Row.swift @@ -766,6 +766,7 @@ extension Row : Collection { } } +/// Row adopts Equatable. extension Row : Equatable { /// Returns true if and only if both rows have the same columns and values, @@ -809,6 +810,15 @@ extension Row : Equatable { } } +/// Row adopts Hashable. +extension Row : Hashable { + /// The hash value + public var hashValue: Int { + return columnNames.reduce(0) { (acc, column) in acc ^ column.hashValue } ^ + databaseValues.reduce(0) { (acc, dbv) in acc ^ dbv.hashValue } + } +} + /// Row adopts CustomStringConvertible. extension Row: CustomStringConvertible { /// A textual representation of `self`.