Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove workarounds for timestamps #218

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmd/connector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ package main

import (
postgres "github.com/conduitio/conduit-connector-postgres"
"github.com/conduitio/conduit-connector-postgres/source/types"
sdk "github.com/conduitio/conduit-connector-sdk"
)

func main() {
// Running as standalone plugin
types.WithBuiltinPlugin = false

sdk.Serve(postgres.Connector)
}
9 changes: 3 additions & 6 deletions source/logrepl/internal/relationset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"testing"
"time"

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

types.WithBuiltinPlugin = false
values, err := rs.Values(ins.RelationID, ins.Tuple)
is.NoErr(err)
isValuesAllTypesStandalone(is, values)
types.WithBuiltinPlugin = true
})
}

Expand Down Expand Up @@ -383,7 +380,7 @@ func isValuesAllTypesStandalone(is *is.I, got map[string]any) {
R: 13,
Valid: true,
},
"col_date": time.Date(2022, 3, 14, 0, 0, 0, 0, time.UTC).UTC().String(),
"col_date": time.Date(2022, 3, 14, 0, 0, 0, 0, time.UTC).UTC(),
"col_float4": float32(15),
"col_float8": float64(16.16),
"col_inet": netip.MustParsePrefix("192.168.0.17/32"),
Expand Down Expand Up @@ -436,8 +433,8 @@ func isValuesAllTypesStandalone(is *is.I, got map[string]any) {
Valid: true,
},
"col_timetz": "04:05:06.789-08",
"col_timestamp": time.Date(2022, 3, 14, 15, 16, 17, 0, time.UTC).UTC().String(),
"col_timestamptz": time.Date(2022, 3, 14, 15+8, 16, 17, 0, time.UTC).UTC().String(),
"col_timestamp": time.Date(2022, 3, 14, 15, 16, 17, 0, time.UTC).UTC(),
"col_timestamptz": time.Date(2022, 3, 14, 15+8, 16, 17, 0, time.UTC).UTC(),
"col_tsquery": "'fat' & ( 'rat' | 'cat' )",
"col_tsvector": "'a' 'and' 'ate' 'cat' 'fat' 'mat' 'on' 'rat' 'sat'",
"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}
Expand Down
31 changes: 0 additions & 31 deletions source/types/time.go

This file was deleted.

9 changes: 0 additions & 9 deletions source/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@
package types

import (
"time"

"github.com/jackc/pgx/v5/pgtype"
)

var (
Numeric = NumericFormatter{}
Time = TimeFormatter{}
UUID = UUIDFormatter{}
)

var WithBuiltinPlugin = true

func Format(oid uint32, v any) (any, error) {
if oid == pgtype.UUIDOID {
return UUID.Format(v)
Expand All @@ -38,10 +33,6 @@ func Format(oid uint32, v any) (any, error) {
return Numeric.Format(t)
case *pgtype.Numeric:
return Numeric.Format(*t)
case time.Time:
return Time.Format(t)
case *time.Time:
return Time.Format(*t)
case []uint8:
if oid == pgtype.XMLOID {
return string(t), nil
Expand Down
26 changes: 0 additions & 26 deletions source/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,6 @@ func Test_Format(t *testing.T) {
float64(12.2121), int64(101), nil, nil,
},
},
{
name: "time.Time",
input: []any{
func() time.Time {
is := is.New(t)
is.Helper()
t, err := time.Parse(time.DateTime, "2009-11-10 23:00:00")
is.NoErr(err)
return t
}(),
nil,
},
inputOID: []uint32{
0, 0,
},
expect: []any{
"2009-11-10 23:00:00 +0000 UTC", nil,
},
},
{
name: "builtin time.Time",
input: []any{
Expand Down Expand Up @@ -107,13 +88,6 @@ func Test_Format(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
is := is.New(t)

prevWithBuiltinPlugin := WithBuiltinPlugin
WithBuiltinPlugin = tc.withBuiltin

t.Cleanup(func() {
WithBuiltinPlugin = prevWithBuiltinPlugin
})

for i, in := range tc.input {
v, err := Format(tc.inputOID[i], in)
is.NoErr(err)
Expand Down