(engine storepb.Engine, value *v1pb.RowValue)
| 82 | } |
| 83 | |
| 84 | func 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 | |
| 120 | func escapeSQLString(engine storepb.Engine, v []byte) []byte { |
| 121 | switch engine { |
no test coverage detected