Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sql/analyzer/costed_index_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ type iScanLeaf struct {

func (l *iScanLeaf) normString() string {
if l.underlying != "" {
return fmt.Sprintf("%s.%s", strings.ToLower(l.underlying), strings.ToLower(l.gf.Name()))
return strings.ToLower(l.underlying) + "." + strings.ToLower(l.gf.Name())
}
return strings.ToLower(l.gf.String())
}
Expand Down
5 changes: 3 additions & 2 deletions sql/planbuilder/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1726,11 +1726,12 @@ func (b *Builder) resolveColumnDefaultExpression(inScope *scope, columnDef *sql.

// Empty string is a special case, it means the default value is the empty string
// TODO: why isn't this serialized as ''
if def.String() == "" {
defStr := def.String()
if defStr == "" {
return b.convertDefaultExpression(inScope, &ast.SQLVal{Val: []byte{}, Type: ast.StrVal}, columnDef.Type, columnDef.Nullable)
}

parsed, err := b.parser.ParseSimple(fmt.Sprintf("SELECT %s", def))
parsed, err := b.parser.ParseSimple("SELECT " + defStr)
if err != nil {
err := sql.ErrInvalidColumnDefaultValue.Wrap(err, def)
b.handleErr(err)
Expand Down
5 changes: 3 additions & 2 deletions sql/types/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"gopkg.in/src-d/go-errors.v1"

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/encodings"
"github.com/dolthub/go-mysql-server/sql/values"
)

Expand Down Expand Up @@ -342,7 +343,7 @@ func (t DecimalType_) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltype
if err != nil {
return sqltypes.Value{}, err
}
val := AppendAndSliceString(dest, t.DecimalValueStringFixed(value.Decimal))
val := encodings.StringToBytes(t.DecimalValueStringFixed(value.Decimal))
return sqltypes.MakeTrusted(sqltypes.Decimal, val), nil
}

Expand All @@ -351,7 +352,7 @@ func (t DecimalType_) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqlt
return sqltypes.NULL, nil
}
d := values.ReadDecimal(v.Val)
return sqltypes.MakeTrusted(sqltypes.Decimal, []byte(t.DecimalValueStringFixed(d))), nil
return sqltypes.MakeTrusted(sqltypes.Decimal, encodings.StringToBytes(t.DecimalValueStringFixed(d))), nil
}

// String implements Type interface.
Expand Down
2 changes: 1 addition & 1 deletion sql/types/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (t EnumType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes
}

// TODO: write append style encoder
res, ok := charset.Encoder().Encode([]byte(value))
res, ok := charset.Encoder().Encode(encodings.StringToBytes(value))
if !ok {
if len(value) > 50 {
value = value[:50]
Expand Down
3 changes: 2 additions & 1 deletion sql/types/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/shopspring/decimal"

"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/encodings"
)

var (
Expand Down Expand Up @@ -166,7 +167,7 @@ func (t JsonType) SQL(ctx *sql.Context, dest []byte, v interface{}) (sqltypes.Va
if err != nil {
return sqltypes.NULL, err
}
val = AppendAndSliceString(dest, str)
val = encodings.StringToBytes(str)
}

return sqltypes.MakeTrusted(sqltypes.TypeJSON, val), nil
Expand Down
2 changes: 1 addition & 1 deletion sql/types/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (t SetType) SQLValue(ctx *sql.Context, v sql.Value, dest []byte) (sqltypes.
}

// TODO: write append style encoder
res, ok := resultCharset.Encoder().Encode([]byte(value))
res, ok := resultCharset.Encoder().Encode(encodings.StringToBytes(value))
if !ok {
if len(value) > 50 {
value = value[:50]
Expand Down