2019-04-03 11:03:07 +02:00
|
|
|
package sqlbuilder
|
|
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
type projection interface {
|
2019-05-08 13:47:01 +02:00
|
|
|
serializeForProjection(statement statementType, out *queryData) error
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------//
|
|
|
|
|
// Dummy type for select * AllColumns
|
2019-06-05 17:15:20 +02:00
|
|
|
type ColumnList []Column
|
2019-04-03 11:03:07 +02:00
|
|
|
|
2019-05-07 19:06:21 +02:00
|
|
|
func (cl ColumnList) isProjectionType() {}
|
|
|
|
|
|
2019-05-08 13:47:01 +02:00
|
|
|
func (cl ColumnList) serializeForProjection(statement statementType, out *queryData) error {
|
2019-04-03 11:03:07 +02:00
|
|
|
for i, column := range cl {
|
2019-05-08 13:47:01 +02:00
|
|
|
err := column.serializeForProjection(statement, out)
|
2019-04-03 11:03:07 +02:00
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if i != len(cl)-1 {
|
2019-05-08 13:47:01 +02:00
|
|
|
out.writeString(", ")
|
2019-04-03 11:03:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|