Skip to content

Commit cbbcf68

Browse files
authored
Remove workarounds for timestamps
1 parent 7f9cf94 commit cbbcf68

File tree

5 files changed

+3
-76
lines changed

5 files changed

+3
-76
lines changed

cmd/connector/main.go

-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ package main
1616

1717
import (
1818
postgres "github.com/conduitio/conduit-connector-postgres"
19-
"github.com/conduitio/conduit-connector-postgres/source/types"
2019
sdk "github.com/conduitio/conduit-connector-sdk"
2120
)
2221

2322
func main() {
24-
// Running as standalone plugin
25-
types.WithBuiltinPlugin = false
26-
2723
sdk.Serve(postgres.Connector)
2824
}

source/logrepl/internal/relationset_test.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"testing"
2424
"time"
2525

26-
"github.com/conduitio/conduit-connector-postgres/source/types"
2726
"github.com/conduitio/conduit-connector-postgres/test"
2827
"github.com/google/go-cmp/cmp"
2928
"github.com/jackc/pglogrepl"
@@ -96,11 +95,9 @@ func TestRelationSetAllTypes(t *testing.T) {
9695
t.Run("with standalone plugin", func(t *testing.T) {
9796
is := is.New(t)
9897

99-
types.WithBuiltinPlugin = false
10098
values, err := rs.Values(ins.RelationID, ins.Tuple)
10199
is.NoErr(err)
102100
isValuesAllTypesStandalone(is, values)
103-
types.WithBuiltinPlugin = true
104101
})
105102
}
106103

@@ -383,7 +380,7 @@ func isValuesAllTypesStandalone(is *is.I, got map[string]any) {
383380
R: 13,
384381
Valid: true,
385382
},
386-
"col_date": time.Date(2022, 3, 14, 0, 0, 0, 0, time.UTC).UTC().String(),
383+
"col_date": time.Date(2022, 3, 14, 0, 0, 0, 0, time.UTC).UTC(),
387384
"col_float4": float32(15),
388385
"col_float8": float64(16.16),
389386
"col_inet": netip.MustParsePrefix("192.168.0.17/32"),
@@ -436,8 +433,8 @@ func isValuesAllTypesStandalone(is *is.I, got map[string]any) {
436433
Valid: true,
437434
},
438435
"col_timetz": "04:05:06.789-08",
439-
"col_timestamp": time.Date(2022, 3, 14, 15, 16, 17, 0, time.UTC).UTC().String(),
440-
"col_timestamptz": time.Date(2022, 3, 14, 15+8, 16, 17, 0, time.UTC).UTC().String(),
436+
"col_timestamp": time.Date(2022, 3, 14, 15, 16, 17, 0, time.UTC).UTC(),
437+
"col_timestamptz": time.Date(2022, 3, 14, 15+8, 16, 17, 0, time.UTC).UTC(),
441438
"col_tsquery": "'fat' & ( 'rat' | 'cat' )",
442439
"col_tsvector": "'a' 'and' 'ate' 'cat' 'fat' 'mat' 'on' 'rat' 'sat'",
443440
"col_uuid": "bd94ee0b-564f-4088-bf4e-8d5e626caf66", // [16]uint8{0xbd, 0x94, 0xee, 0x0b, 0x56, 0x4f, 0x40, 0x88, 0xbf, 0x4e, 0x8d, 0x5e, 0x62, 0x6c, 0xaf, 0x66}

source/types/time.go

-31
This file was deleted.

source/types/types.go

-9
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@
1515
package types
1616

1717
import (
18-
"time"
19-
2018
"github.com/jackc/pgx/v5/pgtype"
2119
)
2220

2321
var (
2422
Numeric = NumericFormatter{}
25-
Time = TimeFormatter{}
2623
UUID = UUIDFormatter{}
2724
)
2825

29-
var WithBuiltinPlugin = true
30-
3126
func Format(oid uint32, v any) (any, error) {
3227
if oid == pgtype.UUIDOID {
3328
return UUID.Format(v)
@@ -38,10 +33,6 @@ func Format(oid uint32, v any) (any, error) {
3833
return Numeric.Format(t)
3934
case *pgtype.Numeric:
4035
return Numeric.Format(*t)
41-
case time.Time:
42-
return Time.Format(t)
43-
case *time.Time:
44-
return Time.Format(*t)
4536
case []uint8:
4637
if oid == pgtype.XMLOID {
4738
return string(t), nil

source/types/types_test.go

-26
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ func Test_Format(t *testing.T) {
5656
float64(12.2121), int64(101), nil, nil,
5757
},
5858
},
59-
{
60-
name: "time.Time",
61-
input: []any{
62-
func() time.Time {
63-
is := is.New(t)
64-
is.Helper()
65-
t, err := time.Parse(time.DateTime, "2009-11-10 23:00:00")
66-
is.NoErr(err)
67-
return t
68-
}(),
69-
nil,
70-
},
71-
inputOID: []uint32{
72-
0, 0,
73-
},
74-
expect: []any{
75-
"2009-11-10 23:00:00 +0000 UTC", nil,
76-
},
77-
},
7859
{
7960
name: "builtin time.Time",
8061
input: []any{
@@ -107,13 +88,6 @@ func Test_Format(t *testing.T) {
10788
t.Run(tc.name, func(t *testing.T) {
10889
is := is.New(t)
10990

110-
prevWithBuiltinPlugin := WithBuiltinPlugin
111-
WithBuiltinPlugin = tc.withBuiltin
112-
113-
t.Cleanup(func() {
114-
WithBuiltinPlugin = prevWithBuiltinPlugin
115-
})
116-
11791
for i, in := range tc.input {
11892
v, err := Format(tc.inputOID[i], in)
11993
is.NoErr(err)

0 commit comments

Comments
 (0)