Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix custom to fully support Codable protocol when using SwiftData #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

t-p-dev
Copy link

@t-p-dev t-p-dev commented Jul 30, 2024

Fixes certain crashes when using NaiveDate/Time with SwiftData.

t-p-dev added 2 commits July 30, 2024 17:43
@t-p-dev t-p-dev changed the title Fix custom decoder to fully support Decodable protocol. Fix custom to fully support Codable protocol when using SwiftData Jul 30, 2024
@moneill
Copy link

moneill commented Aug 10, 2024

Hi @kean and @liamnichols! Any chance of getting this merged in? This fixes some intermittent crashes we encountered when persisting NaiveDate objects with SwiftData. 🙏

}

public func encode(to encoder: Encoder) throws {
try _encode(self, to: encoder)
if String(describing: encoder) == "SwiftData.CompositeEncoder" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to implement it without hardcoding "SwiftData.CompositeEncoder"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I didn't have a time to find a way just yet

@kean
Copy link
Member

kean commented Aug 10, 2024

Hey, sure, let me look into it. Do you what's the root cause of the crash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants