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

     1  package columns
     2  
     3  import "fmt"
     4  
     5  // Column represents a SQL table column.
     6  type Column struct {
     7  	Name      string
     8  	Writeable bool
     9  	Readable  bool
    10  	SelectSQL string
    11  }
    12  
    13  // UpdateString returns the SQL statement to UPDATE the column.
    14  func (c Column) UpdateString() string {
    15  	return fmt.Sprintf("%s = :%s", c.Name, c.Name)
    16  }
    17  
    18  // QuotedUpdateString returns quoted the SQL statement to UPDATE the column.
    19  func (c Column) QuotedUpdateString(quoter quoter) string {
    20  	return fmt.Sprintf("%s = :%s", quoter.Quote(c.Name), c.Name)
    21  }
    22  
    23  // SetSelectSQL sets a custom SELECT statement for the column.
    24  func (c *Column) SetSelectSQL(s string) {
    25  	c.SelectSQL = s
    26  	c.Writeable = false
    27  	c.Readable = true
    28  }