Add ability to exclude columns from ColumnList

This commit is contained in:
go-jet 2021-10-04 11:48:02 +02:00
parent 3015b79926
commit 555ec293fb
2 changed files with 85 additions and 0 deletions

View file

@ -11,6 +11,28 @@ func (cl ColumnList) SET(expression Expression) ColumnAssigment {
}
}
// Except will create new column list in which columns contained in excluded column names are removed
func (cl ColumnList) Except(excludedColumns ...Column) ColumnList {
excludedColumnList := UnwidColumnList(excludedColumns)
excludedColumnNames := map[string]bool{}
for _, excludedColumn := range excludedColumnList {
excludedColumnNames[excludedColumn.Name()] = true
}
var ret ColumnList
for _, column := range cl {
if excludedColumnNames[column.Name()] {
continue
}
ret = append(ret, column)
}
return ret
}
func (cl ColumnList) fromImpl(subQuery SelectTable) Projection {
newProjectionList := ProjectionList{}