Skip to content

Commit df7f0d0

Browse files
author
James Cor
committed
revert and try make
1 parent 44f2157 commit df7f0d0

File tree

6 files changed

+10
-19
lines changed

6 files changed

+10
-19
lines changed

sql/types/decimal.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ func (t DecimalType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltype
303303
if err != nil {
304304
return sqltypes.Value{}, err
305305
}
306-
//val := AppendAndSliceString(dest, t.DecimalValueStringFixed(value.Decimal))
307-
val := []byte(t.DecimalValueStringFixed(value.Decimal))
306+
val := AppendAndSliceString(dest, t.DecimalValueStringFixed(value.Decimal))
308307
return sqltypes.MakeTrusted(sqltypes.Decimal, val), nil
309308
}
310309

sql/types/json.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ func (t JsonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Va
154154
if err != nil {
155155
return sqltypes.NULL, err
156156
}
157-
//val = AppendAndSliceString(dest, str)
158-
val = []byte(str)
157+
val = AppendAndSliceString(dest, str)
159158
}
160159

161160
return sqltypes.MakeTrusted(sqltypes.TypeJSON, val), nil

sql/types/strings.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ func ConvertToBytes(ctx context.Context, v interface{}, t sql.StringType, dest [
480480
val = append(dest, b...)
481481
start = len(dest)
482482
}
483-
val = append(val, bytes.Repeat([]byte{0}, int(st.maxCharLength)-len(val))...)
483+
val = append(val, make([]byte, int(st.maxCharLength)-len(val))...)
484484
}
485485
}
486486
val = val[start:]
@@ -715,10 +715,13 @@ func (t StringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.
715715
var valueBytes []byte
716716
switch v := v.(type) {
717717
case JSONBytes:
718-
valueBytes, err = v.GetBytes(ctx)
718+
// TODO: put on dest?
719+
val, err = v.GetBytes(ctx)
719720
if err != nil {
720721
return sqltypes.Value{}, err
721722
}
723+
dest = append(dest, val...)
724+
valueBytes = dest[start:]
722725
case []byte:
723726
valueBytes = v
724727
case string:
@@ -893,10 +896,3 @@ func AppendAndSliceString(buffer []byte, addition string) (slice []byte) {
893896
slice = buffer[stop:]
894897
return
895898
}
896-
897-
func AppendAndSliceBytes(buffer, addition []byte) (slice []byte) {
898-
stop := len(buffer)
899-
buffer = append(buffer, addition...)
900-
slice = buffer[stop:]
901-
return
902-
}

sql/types/system_enum.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ func (t systemEnumType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqlty
157157
return sqltypes.Value{}, err
158158
}
159159

160-
//val := AppendAndSliceString(dest, v.(string))
161-
val := []byte(v.(string))
160+
val := AppendAndSliceString(dest, v.(string))
162161

163162
return sqltypes.MakeTrusted(t.Type(), val), nil
164163
}

sql/types/system_set.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ func (t systemSetType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltyp
143143
return sqltypes.Value{}, err
144144
}
145145

146-
//val := AppendAndSliceString(dest, value)
147-
val := []byte(value)
146+
val := AppendAndSliceString(dest, value)
148147

149148
return sqltypes.MakeTrusted(t.Type(), val), nil
150149
}

sql/types/system_string.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ func (t systemStringType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sql
102102
return sqltypes.Value{}, err
103103
}
104104

105-
//val := AppendAndSliceString(dest, v.(string))
106-
val := []byte(v.(string))
105+
val := AppendAndSliceString(dest, v.(string))
107106

108107
return sqltypes.MakeTrusted(t.Type(), val), nil
109108
}

0 commit comments

Comments
 (0)