add support for BLOB
This commit is contained in:
		
							parent
							
								
									fb9808a139
								
							
						
					
					
						commit
						2185a61564
					
				@ -82,6 +82,10 @@ func (star *StarRows) setAllRefValue(stc interface{}, skey string, rows int) err
 | 
				
			|||||||
			v.Field(i).SetFloat(star.Row(rows).MustFloat64(seg))
 | 
								v.Field(i).SetFloat(star.Row(rows).MustFloat64(seg))
 | 
				
			||||||
		case reflect.Float32:
 | 
							case reflect.Float32:
 | 
				
			||||||
			v.Field(i).SetFloat(float64(star.Row(rows).MustFloat32(seg)))
 | 
								v.Field(i).SetFloat(float64(star.Row(rows).MustFloat32(seg)))
 | 
				
			||||||
 | 
							case reflect.Slice, reflect.Array:
 | 
				
			||||||
 | 
								if v.Field(i).Elem().Kind() == reflect.Uint8 {
 | 
				
			||||||
 | 
									v.Field(i).SetBytes(star.Row(rows).MustBytes(seg))
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		case reflect.Interface, reflect.Struct, reflect.Ptr:
 | 
							case reflect.Interface, reflect.Struct, reflect.Ptr:
 | 
				
			||||||
			inf := star.Row(rows).Result[star.columnref[seg]]
 | 
								inf := star.Row(rows).Result[star.columnref[seg]]
 | 
				
			||||||
			switch vtype := inf.(type) {
 | 
								switch vtype := inf.(type) {
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,7 @@ type Useless struct {
 | 
				
			|||||||
	Leader string  `db:"leader"`
 | 
						Leader string  `db:"leader"`
 | 
				
			||||||
	Usable bool    `db:"use"`
 | 
						Usable bool    `db:"use"`
 | 
				
			||||||
	O      *Whoami `db:"---"`
 | 
						O      *Whoami `db:"---"`
 | 
				
			||||||
 | 
						Data   []byte  `db:"data"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type Whoami struct {
 | 
					type Whoami struct {
 | 
				
			||||||
@ -29,10 +30,15 @@ func TestUpInOrm(t *testing.T) {
 | 
				
			|||||||
func Test_SetRefVal(t *testing.T) {
 | 
					func Test_SetRefVal(t *testing.T) {
 | 
				
			||||||
	var hehe = Useless{
 | 
						var hehe = Useless{
 | 
				
			||||||
		Leader: "no",
 | 
							Leader: "no",
 | 
				
			||||||
 | 
							Data:   []byte{1, 2, 3},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	fmt.Printf("%+v\n", hehe)
 | 
						fmt.Printf("%+v\n", hehe)
 | 
				
			||||||
	fmt.Println(setRefValue(&hehe, "db", "leader", "sb"))
 | 
						fmt.Println(setRefValue(&hehe, "db", "leader", "sb"))
 | 
				
			||||||
	fmt.Printf("%+v\n", hehe)
 | 
						fmt.Printf("%+v\n", hehe)
 | 
				
			||||||
 | 
						fmt.Println(getAllRefKey(hehe, "db"))
 | 
				
			||||||
 | 
						fmt.Println(getAllRefValue(hehe, "db"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						fmt.Println(setRefValue(&hehe, "db", "data", []byte{4, 5, 6, 7, 8}))
 | 
				
			||||||
	fmt.Printf("%+v\n", hehe)
 | 
						fmt.Printf("%+v\n", hehe)
 | 
				
			||||||
	fmt.Println(getAllRefKey(hehe, "db"))
 | 
						fmt.Println(getAllRefKey(hehe, "db"))
 | 
				
			||||||
	fmt.Println(getAllRefValue(hehe, "db"))
 | 
						fmt.Println(getAllRefValue(hehe, "db"))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user