Skip to content

Commit 38d4d59

Browse files
authored
fix(deps): Update github.com/cloudquery/plugin-sdk/v4 to v4.5.5 (#13297)
Extracted from #13262 Part of #13153 BEGIN_COMMIT_OVERRIDE fix(deps): Update `github.com/cloudquery/plugin-sdk/v4` to v4.5.5 (#13297) fix: Properly handle trailing zeroes in uint64 values when reading END_COMMIT_OVERRIDE
1 parent e245f6b commit 38d4d59

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

plugins/destination/postgresql/client/read.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"database/sql/driver"
66
"fmt"
7+
"math/big"
78
"strings"
89

910
"github.com/apache/arrow/go/v13/arrow"
@@ -134,14 +135,35 @@ func prepareValueForResourceSet(dataType arrow.DataType, v any) (any, error) {
134135
if !vt.Valid {
135136
v = nil
136137
} else {
137-
v = vt.Int.Uint64()
138+
v = numericToUint64(vt)
138139
}
139140
}
140141
return v, nil
141142
}
142143
return v, nil
143144
}
144145

146+
var (
147+
big10 = big.NewInt(10)
148+
)
149+
150+
func numericToUint64(n pgtype.Numeric) uint64 {
151+
if n.Exp < 0 {
152+
panic("unsupported negative exponent")
153+
}
154+
155+
val := n.Int.Uint64()
156+
if n.Exp == 0 {
157+
return val
158+
}
159+
160+
// exp can only be positive for our use-case
161+
return new(big.Int).Mul(
162+
new(big.Int).SetUint64(val),
163+
new(big.Int).Exp(big10, big.NewInt(int64(n.Exp)), nil),
164+
).Uint64()
165+
}
166+
145167
func stringForTime(t pgtype.Time, unit arrow.TimeUnit) string {
146168
extra := ""
147169
hour := t.Microseconds / 1e6 / 60 / 60

plugins/destination/postgresql/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/apache/arrow/go/v13 v13.0.0-20230731205701-112f94971882
7-
github.com/cloudquery/plugin-sdk/v4 v4.5.1
7+
github.com/cloudquery/plugin-sdk/v4 v4.5.5
88
github.com/jackc/pgx-zerolog v0.0.0-20230315001418-f978528409eb
99
github.com/jackc/pgx/v5 v5.3.1
1010
github.com/rs/zerolog v1.29.1

plugins/destination/postgresql/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ github.com/cloudquery/plugin-pb-go v1.9.3 h1:A+TwhOHB68ZnjqrQYnVtWAzmUKEDnKleVG6
5151
github.com/cloudquery/plugin-pb-go v1.9.3/go.mod h1:f00zd6V5mWD+8Qw9U0eb4HD8RnAobwV9byBexE7Qa+0=
5252
github.com/cloudquery/plugin-sdk/v2 v2.7.0 h1:hRXsdEiaOxJtsn/wZMFQC9/jPfU1MeMK3KF+gPGqm7U=
5353
github.com/cloudquery/plugin-sdk/v2 v2.7.0/go.mod h1:pAX6ojIW99b/Vg4CkhnsGkRIzNaVEceYMR+Bdit73ug=
54-
github.com/cloudquery/plugin-sdk/v4 v4.5.1 h1:V6EfHkW6kyYVMSX2S/Fn1b+62bU1jegIuv16Koo2f98=
55-
github.com/cloudquery/plugin-sdk/v4 v4.5.1/go.mod h1:WNTjNp8CPDDSpJHOSaho+MUzntKO6czG6E+yvVe++aA=
54+
github.com/cloudquery/plugin-sdk/v4 v4.5.5 h1:/8yr2zcuIUIK2VF1OoR1iHTL4U0SXBekIpcK8OZfJhY=
55+
github.com/cloudquery/plugin-sdk/v4 v4.5.5/go.mod h1:/2/9y6iODo8jOT0mrAp8K1eogr7+228cy53jK8aUCjY=
5656
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
5757
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
5858
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=

0 commit comments

Comments
 (0)