Example #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{}))
}
Example #2
0
File: scan.go Project: 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
}