diff --git a/pgtype/json.go b/pgtype/json.go index 3f1a750f6..da12b8c90 100644 --- a/pgtype/json.go +++ b/pgtype/json.go @@ -15,7 +15,7 @@ func (JSONCodec) FormatSupported(format int16) bool { } func (JSONCodec) PreferredFormat() int16 { - return TextFormatCode + return BinaryFormatCode } func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan { diff --git a/pgtype/jsonb.go b/pgtype/jsonb.go index 25555e7ff..562334352 100644 --- a/pgtype/jsonb.go +++ b/pgtype/jsonb.go @@ -13,7 +13,7 @@ func (JSONBCodec) FormatSupported(format int16) bool { } func (JSONBCodec) PreferredFormat() int16 { - return TextFormatCode + return BinaryFormatCode } func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan { @@ -42,7 +42,7 @@ func (plan *encodePlanJSONBCodecBinaryWrapper) Encode(value any, buf []byte) (ne func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan { switch format { case BinaryFormatCode: - plan := JSONCodec{}.PlanScan(m, oid, TextFormatCode, target) + plan := JSONCodec{}.PlanScan(m, oid, BinaryFormatCode, target) if plan != nil { return &scanPlanJSONBCodecBinaryUnwrapper{textPlan: plan} }