Skip to content

Commit c4804bb

Browse files
committed
Add support for yugabyte-specific jsonb column
1 parent e557c08 commit c4804bb

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

helpers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func goType(t TypeInfo) (reflect.Type, error) {
3030
return reflect.TypeOf(*new(time.Duration)), nil
3131
case TypeTimestamp:
3232
return reflect.TypeOf(*new(time.Time)), nil
33-
case TypeBlob:
33+
case TypeBlob, TypeJsonb:
3434
return reflect.TypeOf(*new([]byte)), nil
3535
case TypeBoolean:
3636
return reflect.TypeOf(*new(bool)), nil
@@ -137,6 +137,8 @@ func getCassandraBaseType(name string) Type {
137137
return TypeSet
138138
case "TupleType":
139139
return TypeTuple
140+
case "jsonb":
141+
return TypeJsonb
140142
default:
141143
return TypeCustom
142144
}

marshal.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func Marshal(info TypeInfo, value interface{}) ([]byte, error) {
110110
}
111111

112112
switch info.Type() {
113-
case TypeVarchar, TypeAscii, TypeBlob, TypeText:
113+
case TypeVarchar, TypeAscii, TypeBlob, TypeText, TypeJsonb:
114114
return marshalVarchar(info, value)
115115
case TypeBoolean:
116116
return marshalBool(info, value)
@@ -212,7 +212,7 @@ func Unmarshal(info TypeInfo, data []byte, value interface{}) error {
212212
}
213213

214214
switch info.Type() {
215-
case TypeVarchar, TypeAscii, TypeBlob, TypeText:
215+
case TypeVarchar, TypeAscii, TypeBlob, TypeText, TypeJsonb:
216216
return unmarshalVarchar(info, data, value)
217217
case TypeBoolean:
218218
return unmarshalBool(info, data, value)
@@ -2615,6 +2615,7 @@ const (
26152615
TypeSet Type = 0x0022
26162616
TypeUDT Type = 0x0030
26172617
TypeTuple Type = 0x0031
2618+
TypeJsonb Type = 0x0080 // Yugabyte YCQL JSONB
26182619
)
26192620

26202621
// String returns the name of the identifier.
@@ -2672,6 +2673,8 @@ func (t Type) String() string {
26722673
return "varint"
26732674
case TypeTuple:
26742675
return "tuple"
2676+
case TypeJsonb:
2677+
return "jsonb"
26752678
default:
26762679
return fmt.Sprintf("unknown_type_%d", t)
26772680
}

0 commit comments

Comments
 (0)