Fix insert varchar, forbid insert string type (#19580)

Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>

Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
pull/19599/head
shaoyue 2022-09-30 18:48:55 +08:00 committed by GitHub
parent d6406387f8
commit 08ade66c85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -89,7 +89,7 @@ func (f FieldData) AsSchemapb() (*schemapb.FieldData, error) {
},
},
}
case schemapb.DataType_String:
case schemapb.DataType_VarChar:
if len(raw) > 0 {
_, ok := raw[0].(string)
if !ok {

View File

@ -10,9 +10,9 @@ import (
)
func TestFieldData_AsSchemapb(t *testing.T) {
t.Run("string_ok", func(t *testing.T) {
t.Run("varchar_ok", func(t *testing.T) {
fieldData := FieldData{
Type: schemapb.DataType_String,
Type: schemapb.DataType_VarChar,
Field: []interface{}{"a", "b", "c"},
}
raw, _ := json.Marshal(fieldData)
@ -20,9 +20,9 @@ func TestFieldData_AsSchemapb(t *testing.T) {
_, err := fieldData.AsSchemapb()
assert.NoError(t, err)
})
t.Run("string_error", func(t *testing.T) {
t.Run("varchar_error", func(t *testing.T) {
fieldData := FieldData{
Type: schemapb.DataType_String,
Type: schemapb.DataType_VarChar,
Field: []interface{}{1, 2, 3},
}
raw, _ := json.Marshal(fieldData)
@ -30,7 +30,6 @@ func TestFieldData_AsSchemapb(t *testing.T) {
_, err := fieldData.AsSchemapb()
assert.Error(t, err)
})
t.Run("bool_ok", func(t *testing.T) {
fieldData := FieldData{
Type: schemapb.DataType_Bool,
@ -152,9 +151,9 @@ func TestFieldData_AsSchemapb(t *testing.T) {
_, err := fieldData.AsSchemapb()
assert.Error(t, err)
})
t.Run("varchar_not_support", func(t *testing.T) {
t.Run("string_not_support", func(t *testing.T) {
fieldData := FieldData{
Type: schemapb.DataType_VarChar,
Type: schemapb.DataType_String,
Field: []interface{}{"a", "b", "c"},
}
raw, _ := json.Marshal(fieldData)