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
Throw error if @Group key is missing #372
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # Sources/FluentKit/Model/Fields+Codable.swift # Tests/FluentKitTests/FluentKitTests.swift
This is technically semver-patch, but the change in behavior of thrown decoding errors could easily break existing error recovery logic, especially given how long this has been broken. Also people may be relying on the "ignores missing keys" behavior by now. Is it worth it to merge this? |
I think it's worth adding. If anyone retrieves the group and then tries to access the property it's gonna fail right? |
I'm actually not sure if you would hit the |
@gwynne from my experience with fluent-mongo, I believe I ran into |
Can be easily tested there |
// This assertion's validity changes between Swift versions. | ||
//XCTAssertEqual(ObjectIdentifier(type), ObjectIdentifier([String: Any].self), "\(type) != \([String: Any].self)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need to rewrite the test or find another way. At the very least the commented out code should go
Fixes an issue causing
@Group
to silently ignore missing data when decoding (#372).@Group
will now throw an error if required data is missing while decoding. This prevents force unwrap issues due to accessing uninitialized values.Note: It is recommended that you use DTOs to encode/decode your models from your API. Read more here: https://docs.vapor.codes/4.0/fluent/model/#data-transfer-object