We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 16c8f0b + 4c0cddc commit a891777Copy full SHA for a891777
Sources/PostgreSQL/Data/PostgreSQLJSONCustomConvertible.swift
@@ -42,10 +42,15 @@ extension PostgreSQLJSONCustomConvertible {
42
guard let encodable = self as? Encodable else {
43
fatalError("`\(Self.self)` is not `Encodable`.")
44
}
45
- return try PostgreSQLData(
+
46
+ // JSONB requires version number in a first byte
47
+ let jsonBVersion: [UInt8] = [0x01]
48
+ let jsonData = try JSONEncoder().encode(EncoderWrapper(encodable))
49
50
+ return PostgreSQLData(
51
type: .jsonb,
- format: .text,
- data: JSONEncoder().encode(EncoderWrapper(encodable))
52
+ format: .binary,
53
+ data: jsonBVersion + jsonData
54
)
55
56
0 commit comments