Closed
Description
Describe the bug
After upgrading to postgres-nio 1.5.0, our server started crashing with a bunch of errors like this:
[ ERROR ] invalid field: stripe_id type: String error: typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [], debugDescription: "Could not convert to String: <null>", underlyingError: nil)) [request-id: 4A11F25B-AD9C-43EC-BC9B-996A434DBAF2]
The indicated field is non-null on Postgres and non optional on Swift. I discovered that this is happening when the field's value is an empty string, so it would seem like empty strings are being treated as null values.
To Reproduce
- Create non-null text field in postgres.
- Create Vapor model and connect with that field (with a non optional var)
- Add a new row with an empty string.
- Try to fetch that row in Vapor -> it should crash.
Expected behavior
It should return the empty string instead of crashing.
Vapor 4.32.0
Fluent 4.0.0
Postgres-nio 1.5.0
Postrges 11.5