jet/sqlbuilder/projection.go

38 lines
742 B
Go
Raw Normal View History

package sqlbuilder
2019-05-07 19:06:21 +02:00
type projection interface {
serializeForProjection(out *queryData) error
}
//------------------------------------------------------//
// Dummy type for select * AllColumns
2019-05-07 19:06:21 +02:00
type ColumnList []column
2019-05-07 19:06:21 +02:00
func (cl ColumnList) isProjectionType() {}
func (cl ColumnList) serializeForProjection(out *queryData) error {
for i, column := range cl {
2019-05-07 19:06:21 +02:00
err := column.serializeForProjection(out)
if err != nil {
return err
}
if i != len(cl)-1 {
out.WriteString(", ")
}
}
return nil
}
2019-05-03 12:51:57 +02:00
2019-05-07 19:06:21 +02:00
func (cl ColumnList) DefaultAlias() []projection {
newColumnList := []projection{}
2019-05-03 12:51:57 +02:00
for _, column := range cl {
newColumn := column.DefaultAlias()
newColumnList = append(newColumnList, newColumn)
}
return newColumnList
}