Column types refactoring.

This commit is contained in:
zer0sub 2019-03-31 14:07:58 +02:00
parent 38007810c1
commit 033ab1d0da
19 changed files with 746 additions and 396 deletions

View file

@ -1,9 +1,5 @@
package sqlbuilder
import (
"bytes"
)
// A clause that can be used in order by
type OrderByClause interface {
Clause
@ -11,43 +7,43 @@ type OrderByClause interface {
}
// A clause that is selectable.
type Projection interface {
Clause
isProjectionInterface
//type Projection interface {
// Clause
// isProjectionInterface
//
// SerializeSqlForColumnList(out *bytes.Buffer) error
//}
SerializeSqlForColumnList(out *bytes.Buffer) error
}
//type ColumnList []Column
//
//func (cl ColumnList) SerializeSql(out *bytes.Buffer, options ...serializeOption) error {
// for i, column := range cl {
// column.SerializeSql(out)
//
// if i != len(cl)-1 {
// out.WriteString(", ")
// }
// }
// return nil
//}
//
//func (cl ColumnList) isProjectionType() {
//}
//
//func (cl ColumnList) As(name string) Clause {
// panic("Unallowed operation ")
//}
type ColumnList []NonAliasColumn
func (cl ColumnList) SerializeSql(out *bytes.Buffer) error {
for i, column := range cl {
column.SerializeSql(out)
if i != len(cl)-1 {
out.WriteString(", ")
}
}
return nil
}
func (cl ColumnList) isProjectionType() {
}
func (cl ColumnList) As(name string) Projection {
panic("Unallowed operation ")
}
func (cl ColumnList) SerializeSqlForColumnList(out *bytes.Buffer) error {
for i, column := range cl {
column.SerializeSqlForColumnList(out)
if i != len(cl)-1 {
out.WriteString(", ")
}
}
return nil
}
//func (cl ColumnList) SerializeSqlForColumnList(out *bytes.Buffer) error {
// for i, column := range cl {
// column.SerializeSqlForColumnList(out)
//
// if i != len(cl)-1 {
// out.WriteString(", ")
// }
// }
// return nil
//}
//
// Boiler plates ...
@ -63,12 +59,13 @@ type isOrderByClause struct {
func (o *isOrderByClause) isOrderByClauseType() {
}
type isProjectionInterface interface {
isProjectionType()
}
type isProjection struct {
}
func (p *isProjection) isProjectionType() {
}
//
//type isProjectionInterface interface {
// isProjectionType()
//}
//
//type isProjection struct {
//}
//
//func (p *isProjection) isProjectionType() {
//}