Data-swift / ManagedModels

A SwiftData like `@Model` infrastructure for CoreData.
https://www.alwaysrightinstitute.com/managedmodels/
Apache License 2.0
101 stars 3 forks source link

Optional Codable property issue #32

Closed admkopec closed 4 months ago

admkopec commented 4 months ago

After dropping CodableBox a new issue arose when declaring entity attribute as an optional codable type. The NSAttributeDescription's isOptional value is set to false, which is invalid and results in "NSLocalizedDescription=%{PROPERTY}@ is a required value., NSValidationErrorKey=optionalSip, NSValidationErrorValue=null" error upon save when the attribute value is nil.

admkopec commented 4 months ago

I was able to quickly isolate the issue to the getter of valueType. When no attributeValueClassName is present, then this getter returns Any. But it should return Any or Any? depending on value of isOptional.

I'll try to make a quick PR for this.