-
Notifications
You must be signed in to change notification settings - Fork 1
/
AttributeList.go
48 lines (36 loc) · 997 Bytes
/
AttributeList.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package entitystore
import (
"log"
)
// AttributeList lists attributes
func (st *Store) AttributeList(options AttributeQueryOptions) (attributeList []Attribute, err error) {
q := st.AttributeQuery(options)
sqlStr, _, errSql := q.ToSQL()
if errSql != nil {
return attributeList, errSql
}
if st.GetDebug() {
log.Println(sqlStr)
}
attributeMaps, errSelect := st.database.SelectToMapString(sqlStr)
if errSelect != nil {
return nil, err
}
// attributeMaps := []map[string]string{}
// errScan := sqlscan.Select(context.Background(), st.db, &attributeMaps, sqlStr)
// if errScan != nil {
// if errScan == sql.ErrNoRows {
// // sqlscan does not use this anymore
// return nil, errScan
// }
// if sqlscan.NotFound(errScan) {
// return nil, nil
// }
// return nil, err
// }
for i := 0; i < len(attributeMaps); i++ {
attribute := st.NewAttributeFromMap(attributeMaps[i])
attributeList = append(attributeList, attribute)
}
return attributeList, nil
}