MCPcopy Create free account
hub / github.com/fnproject/fn / buildFilterFnQuery

Function buildFilterFnQuery

api/datastore/sql/sql.go:730–757  ·  view source on GitHub ↗
(filter *models.FnFilter)

Source from the content-addressed store, hash-verified

728}
729
730func buildFilterFnQuery(filter *models.FnFilter) (string, []interface{}, error) {
731 if filter == nil {
732 return "", nil, nil
733 }
734 var b bytes.Buffer
735 var args []interface{}
736
737 // where(fmt.Sprintf("image LIKE '%s%%'"), filter.Image) // TODO needs escaping, prob we want prefix query to ignore tags
738 args = where(&b, args, "app_id=? ", filter.AppID)
739
740 if filter.Cursor != "" {
741 s, err := base64.RawURLEncoding.DecodeString(filter.Cursor)
742 if err != nil {
743 return "", args, err
744 }
745 args = where(&b, args, "name>?", string(s))
746 }
747 if filter.Name != "" {
748 args = where(&b, args, "name=?", filter.Name)
749 }
750
751 fmt.Fprintf(&b, ` ORDER BY name ASC`)
752 if filter.PerPage > 0 {
753 fmt.Fprintf(&b, ` LIMIT ?`)
754 args = append(args, filter.PerPage)
755 }
756 return b.String(), args, nil
757}
758
759func where(b *bytes.Buffer, args []interface{}, colOp string, val interface{}) []interface{} {
760 if val == nil {

Callers 1

GetFnsMethod · 0.85

Calls 2

whereFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected