We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
URL doesn't automatically work as a field type with underlying database type 'string'. It can't encode the URL properly.
Have a model with this field:
@Field(key: "link") var link: URL
And a migration like this:
func prepare(on database: Database) async throws { try await database.schema("bookmarks") .id() .field("link", .string, .required) .create() }
Then when you try to create one of these and save it to the database, you get this error:
invalid field: 'link', type: URL, error: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [SomeCodingKey(stringValue: "bookmarks_link (2)", intValue: nil)], debugDescription: "Unable to interpret value of PSQL type TEXT: ByteBuffer { readerIndex: 0, writerIndex: 23, readableBytes: 23, capacity: 23, storageCapacity: 2048, slice: _ByteBufferSlice { 197..<220 }, storage: 0x000000011f00c200 (2048 bytes) }", underlyingError: nil)) [request-id: E5B62897-697A-468F-94A7-F6B5726CC7FB]
The model and field are saved properly to the database.
The text was updated successfully, but these errors were encountered:
gwynne
Successfully merging a pull request may close this issue.
Describe the bug
URL doesn't automatically work as a field type with underlying database type 'string'. It can't encode the URL properly.
To Reproduce
Have a model with this field:
And a migration like this:
Then when you try to create one of these and save it to the database, you get this error:
Expected behavior
The model and field are saved properly to the database.
Environment
The text was updated successfully, but these errors were encountered: