Skip to content

Commit e39b8ed

Browse files
author
James Cor
committed
delete unused error
1 parent 07d6ccb commit e39b8ed

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

sql/convert_value.go

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,90 @@
11
package sql
22

33
import (
4-
"fmt"
5-
64
"github.com/dolthub/go-mysql-server/sql/values"
75

86
"github.com/dolthub/vitess/go/vt/proto/query"
97
)
108

119
// ConvertToValue converts the interface to a sql value.
12-
func ConvertToValue(v interface{}) (Value, error) {
10+
func ConvertToValue(v interface{}) Value {
1311
switch v := v.(type) {
1412
case nil:
1513
return Value{
1614
Typ: query.Type_NULL_TYPE,
1715
Val: nil,
18-
}, nil
16+
}
1917
case int:
2018
return Value{
2119
Typ: query.Type_INT64,
2220
Val: values.WriteInt64(make([]byte, values.Int64Size), int64(v)),
23-
}, nil
21+
}
2422
case int8:
2523
return Value{
2624
Typ: query.Type_INT8,
2725
Val: values.WriteInt8(make([]byte, values.Int8Size), v),
28-
}, nil
26+
}
2927
case int16:
3028
return Value{
3129
Typ: query.Type_INT16,
3230
Val: values.WriteInt16(make([]byte, values.Int16Size), v),
33-
}, nil
31+
}
3432
case int32:
3533
return Value{
3634
Typ: query.Type_INT32,
3735
Val: values.WriteInt32(make([]byte, values.Int32Size), v),
38-
}, nil
36+
}
3937
case int64:
4038
return Value{
4139
Typ: query.Type_INT64,
4240
Val: values.WriteInt64(make([]byte, values.Int64Size), v),
43-
}, nil
41+
}
4442
case uint:
4543
return Value{
4644
Typ: query.Type_UINT64,
4745
Val: values.WriteUint64(make([]byte, values.Uint64Size), uint64(v)),
48-
}, nil
46+
}
4947
case uint8:
5048
return Value{
5149
Typ: query.Type_UINT8,
5250
Val: values.WriteUint8(make([]byte, values.Uint8Size), v),
53-
}, nil
51+
}
5452
case uint16:
5553
return Value{
5654
Typ: query.Type_UINT16,
5755
Val: values.WriteUint16(make([]byte, values.Uint16Size), v),
58-
}, nil
56+
}
5957
case uint32:
6058
return Value{
6159
Typ: query.Type_UINT32,
6260
Val: values.WriteUint32(make([]byte, values.Uint32Size), v),
63-
}, nil
61+
}
6462
case uint64:
6563
return Value{
6664
Typ: query.Type_UINT64,
6765
Val: values.WriteUint64(make([]byte, values.Uint64Size), v),
68-
}, nil
66+
}
6967
case float32:
7068
return Value{
7169
Typ: query.Type_FLOAT32,
7270
Val: values.WriteFloat32(make([]byte, values.Float32Size), v),
73-
}, nil
71+
}
7472
case float64:
7573
return Value{
7674
Typ: query.Type_FLOAT64,
7775
Val: values.WriteFloat64(make([]byte, values.Float64Size), v),
78-
}, nil
76+
}
7977
case string:
8078
return Value{
8179
Typ: query.Type_VARCHAR,
8280
Val: values.WriteString(make([]byte, len(v)), v, values.ByteOrderCollation),
83-
}, nil
81+
}
8482
case []byte:
8583
return Value{
8684
Typ: query.Type_BLOB,
8785
Val: values.WriteBytes(make([]byte, len(v)), v, values.ByteOrderCollation),
88-
}, nil
86+
}
8987
default:
90-
return Value{}, fmt.Errorf("type %T not implemented", v)
88+
return Value{}
9189
}
9290
}

sql/expression/literal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ sqlparser.Injectable = &Literal{}
4141

4242
// NewLiteral creates a new Literal expression.
4343
func NewLiteral(value interface{}, fieldType sql.Type) *Literal {
44-
val2, _ := sql.ConvertToValue(value)
44+
val2 := sql.ConvertToValue(value)
4545
return &Literal{
4646
Val: value,
4747
val2: val2,

0 commit comments

Comments
 (0)