[Breakable] ColumnList is reverted to be a slice.
ColumnList(...) -> ColumnList{...}
IColumnList is removed.
This commit is contained in:
parent
4f86a77b2d
commit
799737d602
30 changed files with 217 additions and 105 deletions
|
|
@ -564,7 +564,9 @@ To run the tests, additional dependencies are required:
|
|||
|
||||
## Versioning
|
||||
|
||||
[SemVer](http://semver.org/) is used for versioning. For the versions available, see the [releases](https://github.com/go-jet/jet/releases).
|
||||
[SemVer](http://semver.org/) is used for versioning. For the versions available, take a look at the [releases](https://github.com/go-jet/jet/releases).
|
||||
For now there is no guarantee that public API will remain backward compatible. Please read the release draft to get acquaint with possible
|
||||
API build breakable change, and how to fix it.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
@ -23,8 +23,8 @@ type ActorTable struct {
|
|||
LastName postgres.ColumnString
|
||||
LastUpdate postgres.ColumnTimestamp
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new ActorTable with assigned alias
|
||||
|
|
@ -53,7 +53,7 @@ func newActorTable() *ActorTable {
|
|||
LastName: LastNameColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn),
|
||||
MutableColumns: postgres.ColumnList(FirstNameColumn, LastNameColumn, LastUpdateColumn),
|
||||
AllColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn},
|
||||
MutableColumns: postgres.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
@ -22,8 +22,8 @@ type CategoryTable struct {
|
|||
Name postgres.ColumnString
|
||||
LastUpdate postgres.ColumnTimestamp
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new CategoryTable with assigned alias
|
||||
|
|
@ -50,7 +50,7 @@ func newCategoryTable() *CategoryTable {
|
|||
Name: NameColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(CategoryIDColumn, NameColumn, LastUpdateColumn),
|
||||
MutableColumns: postgres.ColumnList(NameColumn, LastUpdateColumn),
|
||||
AllColumns: postgres.ColumnList{CategoryIDColumn, NameColumn, LastUpdateColumn},
|
||||
MutableColumns: postgres.ColumnList{NameColumn, LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
@ -32,8 +32,8 @@ type FilmTable struct {
|
|||
SpecialFeatures postgres.ColumnString
|
||||
Fulltext postgres.ColumnString
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new FilmTable with assigned alias
|
||||
|
|
@ -80,7 +80,7 @@ func newFilmTable() *FilmTable {
|
|||
SpecialFeatures: SpecialFeaturesColumn,
|
||||
Fulltext: FulltextColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(FilmIDColumn, TitleColumn, DescriptionColumn, ReleaseYearColumn, LanguageIDColumn, RentalDurationColumn, RentalRateColumn, LengthColumn, ReplacementCostColumn, RatingColumn, LastUpdateColumn, SpecialFeaturesColumn, FulltextColumn),
|
||||
MutableColumns: postgres.ColumnList(TitleColumn, DescriptionColumn, ReleaseYearColumn, LanguageIDColumn, RentalDurationColumn, RentalRateColumn, LengthColumn, ReplacementCostColumn, RatingColumn, LastUpdateColumn, SpecialFeaturesColumn, FulltextColumn),
|
||||
AllColumns: postgres.ColumnList{FilmIDColumn, TitleColumn, DescriptionColumn, ReleaseYearColumn, LanguageIDColumn, RentalDurationColumn, RentalRateColumn, LengthColumn, ReplacementCostColumn, RatingColumn, LastUpdateColumn, SpecialFeaturesColumn, FulltextColumn},
|
||||
MutableColumns: postgres.ColumnList{TitleColumn, DescriptionColumn, ReleaseYearColumn, LanguageIDColumn, RentalDurationColumn, RentalRateColumn, LengthColumn, ReplacementCostColumn, RatingColumn, LastUpdateColumn, SpecialFeaturesColumn, FulltextColumn},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
@ -22,8 +22,8 @@ type FilmActorTable struct {
|
|||
FilmID postgres.ColumnInteger
|
||||
LastUpdate postgres.ColumnTimestamp
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new FilmActorTable with assigned alias
|
||||
|
|
@ -50,7 +50,7 @@ func newFilmActorTable() *FilmActorTable {
|
|||
FilmID: FilmIDColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(ActorIDColumn, FilmIDColumn, LastUpdateColumn),
|
||||
MutableColumns: postgres.ColumnList(LastUpdateColumn),
|
||||
AllColumns: postgres.ColumnList{ActorIDColumn, FilmIDColumn, LastUpdateColumn},
|
||||
MutableColumns: postgres.ColumnList{LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
@ -22,8 +22,8 @@ type FilmCategoryTable struct {
|
|||
CategoryID postgres.ColumnInteger
|
||||
LastUpdate postgres.ColumnTimestamp
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new FilmCategoryTable with assigned alias
|
||||
|
|
@ -50,7 +50,7 @@ func newFilmCategoryTable() *FilmCategoryTable {
|
|||
CategoryID: CategoryIDColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(FilmIDColumn, CategoryIDColumn, LastUpdateColumn),
|
||||
MutableColumns: postgres.ColumnList(LastUpdateColumn),
|
||||
AllColumns: postgres.ColumnList{FilmIDColumn, CategoryIDColumn, LastUpdateColumn},
|
||||
MutableColumns: postgres.ColumnList{LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 08-Aug-19 16:59:58 CEST
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
|
|
@ -22,8 +22,8 @@ type LanguageTable struct {
|
|||
Name postgres.ColumnString
|
||||
LastUpdate postgres.ColumnTimestamp
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new LanguageTable with assigned alias
|
||||
|
|
@ -50,7 +50,7 @@ func newLanguageTable() *LanguageTable {
|
|||
Name: NameColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(LanguageIDColumn, NameColumn, LastUpdateColumn),
|
||||
MutableColumns: postgres.ColumnList(NameColumn, LastUpdateColumn),
|
||||
AllColumns: postgres.ColumnList{LanguageIDColumn, NameColumn, LastUpdateColumn},
|
||||
MutableColumns: postgres.ColumnList{NameColumn, LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
59
examples/quick-start/.gen/jetdb/dvds/view/actor_info.go
Normal file
59
examples/quick-start/.gen/jetdb/dvds/view/actor_info.go
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package view
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/postgres"
|
||||
)
|
||||
|
||||
var ActorInfo = newActorInfoTable()
|
||||
|
||||
type ActorInfoTable struct {
|
||||
postgres.Table
|
||||
|
||||
//Columns
|
||||
ActorID postgres.ColumnInteger
|
||||
FirstName postgres.ColumnString
|
||||
LastName postgres.ColumnString
|
||||
FilmInfo postgres.ColumnString
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new ActorInfoTable with assigned alias
|
||||
func (a *ActorInfoTable) AS(alias string) *ActorInfoTable {
|
||||
aliasTable := newActorInfoTable()
|
||||
|
||||
aliasTable.Table.AS(alias)
|
||||
|
||||
return aliasTable
|
||||
}
|
||||
|
||||
func newActorInfoTable() *ActorInfoTable {
|
||||
var (
|
||||
ActorIDColumn = postgres.IntegerColumn("actor_id")
|
||||
FirstNameColumn = postgres.StringColumn("first_name")
|
||||
LastNameColumn = postgres.StringColumn("last_name")
|
||||
FilmInfoColumn = postgres.StringColumn("film_info")
|
||||
)
|
||||
|
||||
return &ActorInfoTable{
|
||||
Table: postgres.NewTable("dvds", "actor_info", ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn),
|
||||
|
||||
//Columns
|
||||
ActorID: ActorIDColumn,
|
||||
FirstName: FirstNameColumn,
|
||||
LastName: LastNameColumn,
|
||||
FilmInfo: FilmInfoColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn},
|
||||
MutableColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn},
|
||||
}
|
||||
}
|
||||
74
examples/quick-start/.gen/jetdb/dvds/view/customer_list.go
Normal file
74
examples/quick-start/.gen/jetdb/dvds/view/customer_list.go
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
// Generated at Thursday, 26-Sep-19 12:02:13 CEST
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package view
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/postgres"
|
||||
)
|
||||
|
||||
var CustomerList = newCustomerListTable()
|
||||
|
||||
type CustomerListTable struct {
|
||||
postgres.Table
|
||||
|
||||
//Columns
|
||||
ID postgres.ColumnInteger
|
||||
Name postgres.ColumnString
|
||||
Address postgres.ColumnString
|
||||
ZipCode postgres.ColumnString
|
||||
Phone postgres.ColumnString
|
||||
City postgres.ColumnString
|
||||
Country postgres.ColumnString
|
||||
Notes postgres.ColumnString
|
||||
Sid postgres.ColumnInteger
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new CustomerListTable with assigned alias
|
||||
func (a *CustomerListTable) AS(alias string) *CustomerListTable {
|
||||
aliasTable := newCustomerListTable()
|
||||
|
||||
aliasTable.Table.AS(alias)
|
||||
|
||||
return aliasTable
|
||||
}
|
||||
|
||||
func newCustomerListTable() *CustomerListTable {
|
||||
var (
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
NameColumn = postgres.StringColumn("name")
|
||||
AddressColumn = postgres.StringColumn("address")
|
||||
ZipCodeColumn = postgres.StringColumn("zip code")
|
||||
PhoneColumn = postgres.StringColumn("phone")
|
||||
CityColumn = postgres.StringColumn("city")
|
||||
CountryColumn = postgres.StringColumn("country")
|
||||
NotesColumn = postgres.StringColumn("notes")
|
||||
SidColumn = postgres.IntegerColumn("sid")
|
||||
)
|
||||
|
||||
return &CustomerListTable{
|
||||
Table: postgres.NewTable("dvds", "customer_list", IDColumn, NameColumn, AddressColumn, ZipCodeColumn, PhoneColumn, CityColumn, CountryColumn, NotesColumn, SidColumn),
|
||||
|
||||
//Columns
|
||||
ID: IDColumn,
|
||||
Name: NameColumn,
|
||||
Address: AddressColumn,
|
||||
ZipCode: ZipCodeColumn,
|
||||
Phone: PhoneColumn,
|
||||
City: CityColumn,
|
||||
Country: CountryColumn,
|
||||
Notes: NotesColumn,
|
||||
Sid: SidColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList{IDColumn, NameColumn, AddressColumn, ZipCodeColumn, PhoneColumn, CityColumn, CountryColumn, NotesColumn, SidColumn},
|
||||
MutableColumns: postgres.ColumnList{IDColumn, NameColumn, AddressColumn, ZipCodeColumn, PhoneColumn, CityColumn, CountryColumn, NotesColumn, SidColumn},
|
||||
}
|
||||
}
|
||||
|
|
@ -34,8 +34,8 @@ type {{.GoStructName}} struct {
|
|||
{{ToGoIdentifier .Name}} {{dialect.PackageName}}.Column{{.SqlBuilderColumnType}}
|
||||
{{- end}}
|
||||
|
||||
AllColumns {{dialect.PackageName}}.IColumnList
|
||||
MutableColumns {{dialect.PackageName}}.IColumnList
|
||||
AllColumns {{dialect.PackageName}}.ColumnList
|
||||
MutableColumns {{dialect.PackageName}}.ColumnList
|
||||
}
|
||||
|
||||
// creates new {{.GoStructName}} with assigned alias
|
||||
|
|
@ -62,8 +62,8 @@ func new{{.GoStructName}}() *{{.GoStructName}} {
|
|||
{{ToGoIdentifier .Name}}: {{ToGoIdentifier .Name}}Column,
|
||||
{{- end}}
|
||||
|
||||
AllColumns: {{dialect.PackageName}}.ColumnList( {{template "column-list" .Columns}} ),
|
||||
MutableColumns: {{dialect.PackageName}}.ColumnList( {{template "column-list" .MutableColumns}} ),
|
||||
AllColumns: {{dialect.PackageName}}.ColumnList{ {{template "column-list" .Columns}} },
|
||||
MutableColumns: {{dialect.PackageName}}.ColumnList{ {{template "column-list" .MutableColumns}} },
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,28 +99,10 @@ func (c columnImpl) serialize(statement StatementType, out *SQLBuilder, options
|
|||
|
||||
//------------------------------------------------------//
|
||||
|
||||
// IColumnList is used to store list of columns for later reuse as single projection or
|
||||
// column list for UPDATE and INSERT statement.
|
||||
type IColumnList interface {
|
||||
Projection
|
||||
Column
|
||||
// ColumnList is a helper type to support list of columns as single projection
|
||||
type ColumnList []ColumnExpression
|
||||
|
||||
columns() []ColumnExpression
|
||||
}
|
||||
|
||||
// ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement.
|
||||
func ColumnList(columns ...ColumnExpression) IColumnList {
|
||||
return columnListImpl(columns)
|
||||
}
|
||||
|
||||
// ColumnList is redefined type to support list of columns as single Projection
|
||||
type columnListImpl []ColumnExpression
|
||||
|
||||
func (cl columnListImpl) columns() []ColumnExpression {
|
||||
return cl
|
||||
}
|
||||
|
||||
func (cl columnListImpl) fromImpl(subQuery SelectTable) Projection {
|
||||
func (cl ColumnList) fromImpl(subQuery SelectTable) Projection {
|
||||
newProjectionList := ProjectionList{}
|
||||
|
||||
for _, column := range cl {
|
||||
|
|
@ -130,7 +112,7 @@ func (cl columnListImpl) fromImpl(subQuery SelectTable) Projection {
|
|||
return newProjectionList
|
||||
}
|
||||
|
||||
func (cl columnListImpl) serializeForProjection(statement StatementType, out *SQLBuilder) {
|
||||
func (cl ColumnList) serializeForProjection(statement StatementType, out *SQLBuilder) {
|
||||
projections := ColumnListToProjectionList(cl)
|
||||
|
||||
SerializeProjectionList(statement, projections, out)
|
||||
|
|
@ -139,10 +121,10 @@ func (cl columnListImpl) serializeForProjection(statement StatementType, out *SQ
|
|||
// dummy column interface implementation
|
||||
|
||||
// Name is placeholder for ColumnList to implement Column interface
|
||||
func (cl columnListImpl) Name() string { return "" }
|
||||
func (cl ColumnList) Name() string { return "" }
|
||||
|
||||
// TableName is placeholder for ColumnList to implement Column interface
|
||||
func (cl columnListImpl) TableName() string { return "" }
|
||||
func (cl columnListImpl) setTableName(name string) {}
|
||||
func (cl columnListImpl) setSubQuery(subQuery SelectTable) {}
|
||||
func (cl columnListImpl) defaultAlias() string { return "" }
|
||||
func (cl ColumnList) TableName() string { return "" }
|
||||
func (cl ColumnList) setTableName(name string) {}
|
||||
func (cl ColumnList) setSubQuery(subQuery SelectTable) {}
|
||||
func (cl ColumnList) defaultAlias() string { return "" }
|
||||
|
|
|
|||
|
|
@ -147,8 +147,8 @@ func UnwindRowFromValues(value interface{}, values []interface{}) []Serializer {
|
|||
func UnwindColumns(column1 Column, columns ...Column) []Column {
|
||||
columnList := []Column{}
|
||||
|
||||
if val, ok := column1.(IColumnList); ok {
|
||||
for _, col := range val.columns() {
|
||||
if val, ok := column1.(ColumnList); ok {
|
||||
for _, col := range val {
|
||||
columnList = append(columnList, col)
|
||||
}
|
||||
columnList = append(columnList, columns...)
|
||||
|
|
@ -165,8 +165,8 @@ func UnwidColumnList(columns []Column) []Column {
|
|||
ret := []Column{}
|
||||
|
||||
for _, col := range columns {
|
||||
if columnList, ok := col.(IColumnList); ok {
|
||||
for _, c := range columnList.columns() {
|
||||
if columnList, ok := col.(ColumnList); ok {
|
||||
for _, c := range columnList {
|
||||
ret = append(ret, c)
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,8 @@ import "github.com/go-jet/jet/internal/jet"
|
|||
// Column is common column interface for all types of columns.
|
||||
type Column = jet.ColumnExpression
|
||||
|
||||
// IColumnList is used to store list of columns for later reuse as projection or column list for UPDATE and INSERT statement.
|
||||
type IColumnList = jet.IColumnList
|
||||
|
||||
// ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement.
|
||||
var ColumnList = jet.ColumnList
|
||||
type ColumnList = jet.ColumnList
|
||||
|
||||
// ColumnBool is interface for SQL boolean columns.
|
||||
type ColumnBool = jet.ColumnBool
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ INSERT INTO db.table1 (col1) VALUES
|
|||
}
|
||||
|
||||
func TestInsertWithColumnList(t *testing.T) {
|
||||
columnList := ColumnList(table3ColInt, table3StrCol)
|
||||
columnList := ColumnList{table3ColInt}
|
||||
|
||||
columnList = append(columnList, table3StrCol)
|
||||
|
||||
assertStatementSql(t, table3.INSERT(columnList).VALUES(1, 3), `
|
||||
INSERT INTO db.table3 (col_int, col2) VALUES
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ func TestInvalidSelect(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSelectColumnList(t *testing.T) {
|
||||
columnList := ColumnList(table2ColInt, table2ColFloat, table3ColInt)
|
||||
columnList := ColumnList{table2ColInt, table2ColFloat, table3ColInt}
|
||||
|
||||
assertStatementSql(t, SELECT(columnList).FROM(table2), `
|
||||
SELECT table2.col_int AS "table2.col_int",
|
||||
|
|
|
|||
|
|
@ -5,12 +5,8 @@ import "github.com/go-jet/jet/internal/jet"
|
|||
// Column is common column interface for all types of columns.
|
||||
type Column = jet.ColumnExpression
|
||||
|
||||
// IColumnList is used to store list of columns for later reuse as single projection or
|
||||
// column list for UPDATE and INSERT statement.
|
||||
type IColumnList = jet.IColumnList
|
||||
|
||||
// ColumnList function returns list of columns that be used as projection or column list for UPDATE and INSERT statement.
|
||||
var ColumnList = jet.ColumnList
|
||||
type ColumnList = jet.ColumnList
|
||||
|
||||
// ColumnBool is interface for SQL boolean columns.
|
||||
type ColumnBool = jet.ColumnBool
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ INSERT INTO db.table1 (col1) VALUES
|
|||
}
|
||||
|
||||
func TestInsertWithColumnList(t *testing.T) {
|
||||
columnList := ColumnList(table3ColInt, table3StrCol)
|
||||
columnList := ColumnList{table3ColInt, table3StrCol}
|
||||
|
||||
assertStatementSql(t, table3.INSERT(columnList).VALUES(1, 3), `
|
||||
INSERT INTO db.table3 (col_int, col2) VALUES
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ func TestInvalidSelect(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSelectColumnList(t *testing.T) {
|
||||
columnList := ColumnList(table2ColInt, table2ColFloat, table3ColInt)
|
||||
columnList := ColumnList{table2ColInt, table2ColFloat, table3ColInt}
|
||||
|
||||
assertStatementSql(t, SELECT(columnList).FROM(table2), `
|
||||
SELECT table2.col_int AS "table2.col_int",
|
||||
|
|
|
|||
|
|
@ -137,8 +137,8 @@ type ActorTable struct {
|
|||
LastName mysql.ColumnString
|
||||
LastUpdate mysql.ColumnTimestamp
|
||||
|
||||
AllColumns mysql.IColumnList
|
||||
MutableColumns mysql.IColumnList
|
||||
AllColumns mysql.ColumnList
|
||||
MutableColumns mysql.ColumnList
|
||||
}
|
||||
|
||||
// creates new ActorTable with assigned alias
|
||||
|
|
@ -167,8 +167,8 @@ func newActorTable() *ActorTable {
|
|||
LastName: LastNameColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: mysql.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn),
|
||||
MutableColumns: mysql.ColumnList(FirstNameColumn, LastNameColumn, LastUpdateColumn),
|
||||
AllColumns: mysql.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn},
|
||||
MutableColumns: mysql.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
@ -206,8 +206,8 @@ type ActorInfoTable struct {
|
|||
LastName mysql.ColumnString
|
||||
FilmInfo mysql.ColumnString
|
||||
|
||||
AllColumns mysql.IColumnList
|
||||
MutableColumns mysql.IColumnList
|
||||
AllColumns mysql.ColumnList
|
||||
MutableColumns mysql.ColumnList
|
||||
}
|
||||
|
||||
// creates new ActorInfoTable with assigned alias
|
||||
|
|
@ -236,8 +236,8 @@ func newActorInfoTable() *ActorInfoTable {
|
|||
LastName: LastNameColumn,
|
||||
FilmInfo: FilmInfoColumn,
|
||||
|
||||
AllColumns: mysql.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn),
|
||||
MutableColumns: mysql.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn),
|
||||
AllColumns: mysql.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn},
|
||||
MutableColumns: mysql.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn},
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
|
|||
Name: "DuckDuckGo",
|
||||
}
|
||||
|
||||
updateColumnList := ColumnList(Link.Description, Link.Name, Link.URL)
|
||||
updateColumnList := ColumnList{Link.Description, Link.Name, Link.URL}
|
||||
|
||||
stmt := Link.
|
||||
UPDATE(updateColumnList).
|
||||
|
|
|
|||
|
|
@ -171,8 +171,8 @@ type ActorTable struct {
|
|||
LastName postgres.ColumnString
|
||||
LastUpdate postgres.ColumnTimestamp
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new ActorTable with assigned alias
|
||||
|
|
@ -201,8 +201,8 @@ func newActorTable() *ActorTable {
|
|||
LastName: LastNameColumn,
|
||||
LastUpdate: LastUpdateColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn),
|
||||
MutableColumns: postgres.ColumnList(FirstNameColumn, LastNameColumn, LastUpdateColumn),
|
||||
AllColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn},
|
||||
MutableColumns: postgres.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn},
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
@ -240,8 +240,8 @@ type ActorInfoTable struct {
|
|||
LastName postgres.ColumnString
|
||||
FilmInfo postgres.ColumnString
|
||||
|
||||
AllColumns postgres.IColumnList
|
||||
MutableColumns postgres.IColumnList
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
// creates new ActorInfoTable with assigned alias
|
||||
|
|
@ -270,8 +270,8 @@ func newActorInfoTable() *ActorInfoTable {
|
|||
LastName: LastNameColumn,
|
||||
FilmInfo: FilmInfoColumn,
|
||||
|
||||
AllColumns: postgres.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn),
|
||||
MutableColumns: postgres.ColumnList(ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn),
|
||||
AllColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn},
|
||||
MutableColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn},
|
||||
}
|
||||
}
|
||||
`
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ func TestUpdateWithModelDataAndPredefinedColumnList(t *testing.T) {
|
|||
Name: "DuckDuckGo",
|
||||
}
|
||||
|
||||
updateColumnList := ColumnList(Link.Description, Link.Name, Link.URL)
|
||||
updateColumnList := ColumnList{Link.Description, Link.Name, Link.URL}
|
||||
|
||||
stmt := Link.
|
||||
UPDATE(updateColumnList).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue