postgres-nio
postgres-nio copied to clipboard
When loading data type as jsonb, an extra unicode will be added: \u0001
Describe the issue
loading data type as jsonb, an extra unicode will be added: \u0001 (show in json result) or \u{01} (show in Xcode)
Vapor version
1.26.2
Operating system and version
macOS 26 DP Beta 1 and Ubuntu Linux 22.04
Swift version
macOS: 6.1.2, Ubuntu: swift-6.1.0-release
Steps to reproduce
- Upgrade all packages to latest version;
- Connect PostgreSQL and query a type as
jsonbfield; - the result ByteBuffer decode to String.self, an additional \u{01} will be displayed (in Xcode Console); return it as json to response, it will show \u0001 (additional)
-
in Xcode Console
-
in Postman response raw
-
in DB (it is correct)
Additional notes
When I downgraded back to 1.24.0, everything worked fine!!
If more information is needed, please let me know
@natebird @rgcottrell @ts @shnhrrsn please check it!
@iWECon good catch. Postgres signals jsonb with this extra character. Would you be interested in proposing a PR that fixes this issue?
When I downgraded back to
1.24.0, everything worked fine!!
Oh that sounds weird. I don't think we changed anything in there. But let me recheck.
@iWECon good catch. Postgres signals jsonb with this extra character. Would you be interested in proposing a PR that fixes this issue?
When I downgraded back to
1.24.0, everything worked fine!!Oh that sounds weird. I don't think we changed anything in there. But let me recheck.
Yes, I have checked versions 1.26.2 to 1.24.0, and I have not found any related codes.
In addition, the versions written above are all postgres-nio versions, and vapor is the latest version.
I believe this was introduced in https://github.com/vapor/postgres-nio/pull/548 - I'm also seeing something similar with it working on 1.25.0 but breaking in 1.26.0
@0xTim Good point, but how has json -> String worked before #548?
@fabianfett I have no idea, I'm assuming it was falling back to something on a path that's now missed? But it definitely worked - one project I'm on has pinned to 1.25.0 to work around. Want a PR?
yes, I'm happy to accept such a pr. with test case, please :)