postgres-kit icon indicating copy to clipboard operation
postgres-kit copied to clipboard

URL is unable to be decoded

Open jaekong opened this issue 4 years ago • 0 comments

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.
  1. Use Vapor/Fluent and PostgresKit package 2.3.3.
  2. Make a model with a URL field, and two endpoints - one for creating object, the other for fetching.
  3. Send a request to create and store the object on the database.
  4. Send another request to read the object.
  5. 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.

jaekong avatar Nov 04 '21 17:11 jaekong