Closed
Description
Build Information
- Version: 0.11.5
- macOS 10.13.6
- CocoaPods integration
General guidelines
If you run try db.run(table.filter(id == desiredID).update(modelObject))
where modelObject
is a Codable
struct containing an optional value where the corresponding column is defined as nullable, the SQL generated will not include the set to null as expected.
Example:
struct DBAllocation: Codable {
let amount: Double
let note: String
let strategy: AllocationInterval.Datatype
let tag_id: Int?
let start_date: Date.Datatype
let end_date: Date.Datatype?
}
Executing the update with the above struct where end_date
is nil produces the following SQL
UPDATE "allocations" SET "amount" = 60.0, "note" = 'Electric', "strategy" = 'Monthly', "tag_id" = 4, "start_date" = '2018-08-01T07:00:00.000' WHERE ("id" = 5)
which excludes the end_date
column set to NULL as I'd expect.