jet/sqlbuilder/projection.go

38 lines
803 B
Go
Raw Normal View History

package sqlbuilder
2019-05-07 19:06:21 +02:00
type projection interface {
serializeForProjection(statement statementType, out *queryData) error
}
//------------------------------------------------------//
// Dummy type for select * AllColumns
2019-06-05 17:15:20 +02:00
type ColumnList []Column
2019-05-07 19:06:21 +02:00
func (cl ColumnList) isProjectionType() {}
func (cl ColumnList) serializeForProjection(statement statementType, out *queryData) error {
for i, column := range cl {
err := column.serializeForProjection(statement, 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
}