github.com/paweljw/pop@v4.13.1+incompatible/columns/writeable_columns.go (about)

     1  package columns
     2  
     3  import (
     4  	"sort"
     5  	"strings"
     6  )
     7  
     8  // WriteableColumns represents a list of columns Pop is allowed to write.
     9  type WriteableColumns struct {
    10  	Columns
    11  }
    12  
    13  // UpdateString returns the SQL column list part of the UPDATE query.
    14  func (c WriteableColumns) UpdateString() string {
    15  	var xs []string
    16  	for _, t := range c.Cols {
    17  		xs = append(xs, t.UpdateString())
    18  	}
    19  	sort.Strings(xs)
    20  	return strings.Join(xs, ", ")
    21  }
    22  
    23  // QuotedUpdateString returns the quoted SQL column list part of the UPDATE query.
    24  func (c Columns) QuotedUpdateString(quoter quoter) string {
    25  	var xs []string
    26  	for _, t := range c.Cols {
    27  		xs = append(xs, t.QuotedUpdateString(quoter))
    28  	}
    29  	sort.Strings(xs)
    30  	return strings.Join(xs, ", ")
    31  }