You will only see the public (readable) repos here until you login.

column.go 684 B

12345678910111213141516171819202122232425262728293031323334
  1. package orm
  2. // column is a column in a table
  3. type column struct {
  4. field
  5. ref string
  6. }
  7. // GetName returns the name. If relation is given, it
  8. // will return `tbl`.`col` retpr
  9. func (c column) getName(q bool, rel ...interface{}) string {
  10. if len(rel) > 0 {
  11. switch rel[0].(type) {
  12. case relation:
  13. return ((rel[0]).(relation)).getAlias(q) + "." + c.getName(q)
  14. case *table:
  15. return ((rel[0]).(*table)).getAlias(q) + "." + c.getName(q)
  16. }
  17. }
  18. if q {
  19. return SqlFlavor.Quote(c.ref)
  20. }
  21. return c.ref
  22. }
  23. func (c column) GetAs(q bool, rel ...interface{}) string {
  24. return c.getName(q, rel) + " AS "
  25. }
  26. // columns is the collection of all columns in a table
  27. type columns []column