![]() This adds and implements `open func modifyValue(_ v: Any?, forKey k: String) -> Any` to the `StORM` class. The intent of this addition is to allow base classes to optionally change the data sent to the database. For example, I am using it to properly handle `Optional`s and the `Date` class in PostgreSQL as follows: ```swift override func modifyValue(_ val: Any, forKey k: String) -> Any { var v = val if let o = val as? OptionalProtocol { if o.isSome() { v = o.unwrap() // not-nil } else { return "" // nil } } // After this point, v is guarenteed to not be optional or nil if let d = v as? Date { return d.timestamptz } return v } ``` The implementations of `OptionalProtocol` and `timestamptz` are irrelevant for this pr. The `forKey` parameter is there in case someone wants to switch based on name, not on value. The name is just a placeholder, so feel free to change it if you think of something better. |
||
---|---|---|
.. | ||
StORM |