gitlab.com/picnic-app/backend/role-api@v0.0.0-20230614140944-06a76ff3696d/internal/repo/spanner/tables/tables.go (about)

     1  package tables
     2  
     3  type Table interface {
     4  	TableName() string
     5  	Columns() []string
     6  }
     7  
     8  func Get() AllTables { return AllTables{} }
     9  
    10  func WithAlias(alias string) AllTables { return AllTables{alias: alias} }
    11  
    12  type AllTables struct{ alias string }
    13  
    14  func aliasedTable(alias, table string) string {
    15  	if alias == "" {
    16  		return table
    17  	}
    18  	return table + " AS " + alias
    19  }
    20  
    21  func aliasedCol(alias, col string) string {
    22  	if alias == "" {
    23  		return col
    24  	}
    25  	return alias + "." + col
    26  }