mirror of https://github.com/milvus-io/milvus.git
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
parent
d6406387f8
commit
08ade66c85
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue