Skip to content

Commit 0da89c9

Browse files
committed
improve pg type stringification
1 parent 836562e commit 0da89c9

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* Added query pool metrics
44
* Fixed logic of query session pool
55
* Changed initialization of internal driver clients to lazy
6-
* Disabled the logic of background grpc-connection parking
6+
* Disabled the logic of background grpc-connection parking
7+
* Improved stringification for postgres types
78

89
## v3.58.2
910
* Added `trace.Query.OnSessionBegin` event

internal/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ func (v PgType) String() string {
479479
}
480480

481481
func (v PgType) Yql() string {
482-
return "pgunknown"
482+
return fmt.Sprintf("PgType(%v)", v.OID)
483483
}
484484

485485
func (v PgType) ToYDB(a *allocator.Allocator) *Ydb.Type {

internal/types/types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func TestTypeToString(t *testing.T) {
271271
},
272272
{
273273
t: PgType{OID: pg.OIDUnknown},
274-
s: "pgunknown",
274+
s: "PgType(705)",
275275
},
276276
} {
277277
t.Run(tt.s, func(t *testing.T) {

internal/value/value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ func (v pgValue) Yql() string {
12671267
//nolint:godox
12681268
// TODO: call special function for unknown oids
12691269
// https://github.com/ydb-platform/ydb/issues/2706
1270-
return fmt.Sprintf("PgUnknown(%q)", v.val)
1270+
return fmt.Sprintf(`PgConst("%v", PgType(%v))`, v.val, v.t.OID)
12711271
}
12721272

12731273
type setValue struct {

internal/value/value_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func TestValueYql(t *testing.T) {
502502
},
503503
{
504504
value: PgValue(pg.OIDUnknown, "123"),
505-
literal: `PgUnknown("123")`,
505+
literal: `PgConst("123", PgType(705))`,
506506
},
507507
} {
508508
t.Run(strconv.Itoa(i)+"."+tt.literal, func(t *testing.T) {

0 commit comments

Comments
 (0)