Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
rahul2393 committed Nov 1, 2022
1 parent 1f6dda8 commit fa13c3a
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions spanner/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ type NullRow struct {
// PGJsonB represents a Cloud Spanner PGJsonB that may be NULL.
type PGJsonB struct {
Value interface{} // Val contains the value when it is non-NULL, and nil when NULL.
Valid bool // Valid is true if PGJsonB is not NULL.
Valid bool // Valid is true if PGJsonB is not NULL.
}

// IsNull implements NullableValue.IsNull for PGJsonB.
Expand Down Expand Up @@ -1689,43 +1689,43 @@ func decodeValue(v *proto3.Value, t *sppb.Type, ptr interface{}, opts ...decodeO
}
*p = y
case *PGJsonB:
if p == nil {
return errNilDst(p)
}
if code != sppb.TypeCode_JSON || typeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
return errTypeMismatch(code, acode, ptr)
}
if isNull {
*p = PGJsonB{}
break
}
x := v.GetStringValue()
var y interface{}
err := json.Unmarshal([]byte(x), &y)
if err != nil {
return err
}
*p = PGJsonB{y, true}
case *[]PGJsonB:
if p == nil {
return errNilDst(p)
}
if acode != sppb.TypeCode_JSON || typeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
return errTypeMismatch(code, acode, ptr)
}
if isNull {
*p = nil
break
}
x, err := getListValue(v)
if err != nil {
return err
}
y, err := decodePGJsonBArray(x)
if err != nil {
return err
}
*p = y
if p == nil {
return errNilDst(p)
}
if code != sppb.TypeCode_JSON || typeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
return errTypeMismatch(code, acode, ptr)
}
if isNull {
*p = PGJsonB{}
break
}
x := v.GetStringValue()
var y interface{}
err := json.Unmarshal([]byte(x), &y)
if err != nil {
return err
}
*p = PGJsonB{y, true}
case *[]PGJsonB:
if p == nil {
return errNilDst(p)
}
if acode != sppb.TypeCode_JSON || typeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
return errTypeMismatch(code, acode, ptr)
}
if isNull {
*p = nil
break
}
x, err := getListValue(v)
if err != nil {
return err
}
y, err := decodePGJsonBArray(x)
if err != nil {
return err
}
*p = y
case *time.Time:
var nt NullTime
if isNull {
Expand Down Expand Up @@ -2141,7 +2141,7 @@ func getDecodableSpannerType(ptr interface{}, isPtr bool) decodableSpannerType {
return spannerTypePGNumeric
}
if t.ConvertibleTo(typeOfPGJsonB) {
return spannerTypePGJsonB
return spannerTypePGJsonB
}
case reflect.Slice:
kind := val.Type().Elem().Kind()
Expand Down Expand Up @@ -2365,7 +2365,7 @@ func (dsc decodableSpannerType) decodeValueToCustomType(v *proto3.Value, t *sppb
}
result = &NullJSON{y, true}
case spannerTypePGJsonB:
if code != sppb.TypeCode_JSON || typeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
if code != sppb.TypeCode_JSON || typeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
return errTypeMismatch(code, acode, ptr)
}
if isNull {
Expand Down Expand Up @@ -2548,7 +2548,7 @@ func (dsc decodableSpannerType) decodeValueToCustomType(v *proto3.Value, t *sppb
}
result = y
case spannerTypeArrayOfPGJsonB:
if acode != sppb.TypeCode_JSON || atypeAnnotation != sppb.TypeAnnotationCode_PG_JSONB{
if acode != sppb.TypeCode_JSON || atypeAnnotation != sppb.TypeAnnotationCode_PG_JSONB {
return errTypeMismatch(code, acode, ptr)
}
if isNull {
Expand Down Expand Up @@ -2942,7 +2942,7 @@ func decodeNullJSONArray(pb *proto3.ListValue) ([]NullJSON, error) {
}

// decodeJsonBArray decodes proto3.ListValue pb into a JsonB slice.
func decodePGJsonBArray(pb *proto3.ListValue) ([]JsonB, error) {
func decodePGJsonBArray(pb *proto3.ListValue) ([]PGJsonB, error) {
if pb == nil {
return nil, errNilListValue("PGJSONB")
}
Expand Down Expand Up @@ -3604,17 +3604,17 @@ func encodeValue(v interface{}) (*proto3.Value, *sppb.Type, error) {
if v.Valid {
b, err := json.Marshal(v.Value)
if err != nil {
return nil, nil, err
}
return nil, nil, err
}
pb.Kind = stringKind(string(b))
}
return pb, pgJsonBType(), nil
case []PGJsonB:
if v != nil {
pb, err = encodeArray(len(v), func(i int) interface{} { return v[i] })
if err != nil {
return nil, nil, err
}
return nil, nil, err
}
}
pt = listType(pgJsonBType())
case *big.Rat:
Expand Down

0 comments on commit fa13c3a

Please sign in to comment.