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

Function convertValueToBytesInSQL

backend/component/export/sql.go:84–118  ·  view source on GitHub ↗
(engine storepb.Engine, value *v1pb.RowValue)

Source from the content-addressed store, hash-verified

82}
83
84func convertValueToBytesInSQL(engine storepb.Engine, value *v1pb.RowValue) []byte {
85 if value == nil || value.Kind == nil {
86 return []byte("")
87 }
88 switch value.Kind.(type) {
89 case *v1pb.RowValue_StringValue:
90 return escapeSQLString(engine, []byte(value.GetStringValue()))
91 case *v1pb.RowValue_Int32Value:
92 return []byte(strconv.FormatInt(int64(value.GetInt32Value()), 10))
93 case *v1pb.RowValue_Int64Value:
94 return []byte(strconv.FormatInt(value.GetInt64Value(), 10))
95 case *v1pb.RowValue_Uint32Value:
96 return []byte(strconv.FormatUint(uint64(value.GetUint32Value()), 10))
97 case *v1pb.RowValue_Uint64Value:
98 return []byte(strconv.FormatUint(value.GetUint64Value(), 10))
99 case *v1pb.RowValue_FloatValue:
100 return []byte(strconv.FormatFloat(float64(value.GetFloatValue()), 'f', -1, 32))
101 case *v1pb.RowValue_DoubleValue:
102 return []byte(strconv.FormatFloat(value.GetDoubleValue(), 'f', -1, 64))
103 case *v1pb.RowValue_BoolValue:
104 return []byte(strconv.FormatBool(value.GetBoolValue()))
105 case *v1pb.RowValue_BytesValue:
106 return escapeSQLBytes(engine, value.GetBytesValue())
107 case *v1pb.RowValue_NullValue:
108 return []byte("NULL")
109 case *v1pb.RowValue_TimestampValue:
110 return escapeSQLString(engine, []byte(formatTimestamp(value.GetTimestampValue())))
111 case *v1pb.RowValue_TimestampTzValue:
112 return escapeSQLString(engine, []byte(formatTimestampTz(value.GetTimestampTzValue())))
113 case *v1pb.RowValue_ValueValue:
114 return convertValueValueToBytes(value.GetValueValue())
115 default:
116 return []byte("")
117 }
118}
119
120func escapeSQLString(engine storepb.Engine, v []byte) []byte {
121 switch engine {

Callers 1

SQLToWriterFunction · 0.85

Calls 15

escapeSQLStringFunction · 0.85
escapeSQLBytesFunction · 0.85
formatTimestampTzFunction · 0.85
convertValueValueToBytesFunction · 0.85
GetStringValueMethod · 0.80
GetInt32ValueMethod · 0.80
GetInt64ValueMethod · 0.80
GetUint32ValueMethod · 0.80
GetUint64ValueMethod · 0.80
GetFloatValueMethod · 0.80
GetDoubleValueMethod · 0.80
GetBoolValueMethod · 0.80

Tested by

no test coverage detected