postgres-kit
postgres-kit copied to clipboard
URL is unable to be decoded
Describe the bug
At some point after 2.3.0, PostgresKit cannot decode Foundation's URL struct stored in database.
To Reproduce
- I am using Vapor and Fluent. But I am guessing that it is reproducible on postgres-kit's own.
- Use Vapor/Fluent and PostgresKit package 2.3.3.
- Make a model with a URL field, and two endpoints - one for creating object, the other for fetching.
- Send a request to create and store the object on the database.
- Send another request to read the object.
- See error below.
{
"error": true,
"reason": "invalid field: fieldname type: Optional error: typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [], debugDescription: \"Expected to decode String but found a dictionary instead.\", underlyingError: nil))"
}
Expected behavior
An object with stored URL will be returned.
Environment
- Vapor Framework version: 4.52.1
- Vapor Toolbox version: 18.3.3
- OS version: macOS 12.0.1
Additional context
- Once I manually added PostgresKit 2.3.0 as dependency to my project, it started working just fine.
- Data is safely stored on the database, even on 2.3.3. The error only occurs when you try to decode it afterwards.