예제 #1
0
func TestHasPointers(t *testing.T) {
	assert.True(t, meta.HasPointers([]*Foo{}))
	assert.True(t, meta.HasPointers(&[]*Foo{}))
	assert.False(t, meta.HasPointers([]Foo{}))
	assert.False(t, meta.HasPointers(&[]Foo{}))
	assert.True(t, meta.HasPointers(&Foo{}))
	assert.False(t, meta.HasPointers(Foo{}))
}
예제 #2
0
파일: scan.go 프로젝트: rjp/crud
func NewScan(to interface{}) (*Scan, error) {
	scan := &Scan{
		To:         to,
		ToPointers: meta.HasPointers(to),
		ToStructs:  meta.HasAnyStruct(to),
	}

	if scan.ToStructs {
		table, err := NewTable(to)
		if err != nil {
			return nil, err
		}

		scan.Table = table
		scan.SQLColumnDict = table.SQLColumnDict()
	}

	return scan, nil
}