MCPcopy Create free account
hub / github.com/bytebase/bytebase / BuildTimestampOrStringRowValue

Function BuildTimestampOrStringRowValue

backend/plugin/db/util/driverutil.go:61–80  ·  view source on GitHub ↗
(value string, scale int64)

Source from the content-addressed store, hash-verified

59}
60
61func BuildTimestampOrStringRowValue(value string, scale int64) *v1pb.RowValue {
62 t, err := parseSQLTimestamp(value)
63 if err != nil {
64 return BuildStringRowValue(value)
65 }
66
67 ts := timestamppb.New(t)
68 if err := ts.CheckValid(); err != nil {
69 return BuildStringRowValue(value)
70 }
71
72 return &v1pb.RowValue{
73 Kind: &v1pb.RowValue_TimestampValue{
74 TimestampValue: &v1pb.RowValue_Timestamp{
75 GoogleTimestamp: ts,
76 Accuracy: int32(scale),
77 },
78 },
79 }
80}
81
82func parseSQLTimestamp(value string) (time.Time, error) {
83 if strings.Contains(value, ".") {

Callers 4

convertValueFunction · 0.92
convertValueFunction · 0.92
convertValueFunction · 0.92

Calls 2

parseSQLTimestampFunction · 0.85
BuildStringRowValueFunction · 0.85

Tested by 1