diff --git a/examples/quick-start/.gen/jetdb/dvds/enum/mpaa_rating.go b/examples/quick-start/.gen/jetdb/dvds/enum/mpaa_rating.go index e1dd269..60cb23b 100644 --- a/examples/quick-start/.gen/jetdb/dvds/enum/mpaa_rating.go +++ b/examples/quick-start/.gen/jetdb/dvds/enum/mpaa_rating.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/actor.go b/examples/quick-start/.gen/jetdb/dvds/model/actor.go index 56222ed..922dff5 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/actor.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/actor.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/category.go b/examples/quick-start/.gen/jetdb/dvds/model/category.go index 354d71b..a447fba 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/category.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/category.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/film.go b/examples/quick-start/.gen/jetdb/dvds/model/film.go index 0ccaa83..04a1ae5 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/film.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/film.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/film_actor.go b/examples/quick-start/.gen/jetdb/dvds/model/film_actor.go index 7e0aa87..f0fe9f4 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/film_actor.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/film_actor.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/film_category.go b/examples/quick-start/.gen/jetdb/dvds/model/film_category.go index 846e554..97fe013 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/film_category.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/film_category.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/language.go b/examples/quick-start/.gen/jetdb/dvds/model/language.go index 3e4bc17..ef0e592 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/language.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/language.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/model/mpaa_rating.go b/examples/quick-start/.gen/jetdb/dvds/model/mpaa_rating.go index 821a11f..c802aa9 100644 --- a/examples/quick-start/.gen/jetdb/dvds/model/mpaa_rating.go +++ b/examples/quick-start/.gen/jetdb/dvds/model/mpaa_rating.go @@ -1,6 +1,5 @@ // // 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 diff --git a/examples/quick-start/.gen/jetdb/dvds/table/actor.go b/examples/quick-start/.gen/jetdb/dvds/table/actor.go index d86132c..4332015 100644 --- a/examples/quick-start/.gen/jetdb/dvds/table/actor.go +++ b/examples/quick-start/.gen/jetdb/dvds/table/actor.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var Actor = newActorTable() -type ActorTable struct { +type actorTable struct { postgres.Table //Columns @@ -27,25 +26,38 @@ type ActorTable struct { MutableColumns postgres.ColumnList } -// creates new ActorTable with assigned alias +type ActorTable struct { + actorTable + + EXCLUDED actorTable +} + +// AS creates new ActorTable with assigned alias func (a *ActorTable) AS(alias string) *ActorTable { aliasTable := newActorTable() - aliasTable.Table.AS(alias) - return aliasTable } func newActorTable() *ActorTable { + return &ActorTable{ + actorTable: newActorTableImpl("dvds", "actor"), + EXCLUDED: newActorTableImpl("", "excluded"), + } +} + +func newActorTableImpl(schemaName, tableName string) actorTable { var ( ActorIDColumn = postgres.IntegerColumn("actor_id") FirstNameColumn = postgres.StringColumn("first_name") LastNameColumn = postgres.StringColumn("last_name") LastUpdateColumn = postgres.TimestampColumn("last_update") + allColumns = postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn} + mutableColumns = postgres.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn} ) - return &ActorTable{ - Table: postgres.NewTable("dvds", "actor", ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn), + return actorTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns ActorID: ActorIDColumn, @@ -53,7 +65,7 @@ func newActorTable() *ActorTable { LastName: LastNameColumn, LastUpdate: LastUpdateColumn, - AllColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, LastUpdateColumn}, - MutableColumns: postgres.ColumnList{FirstNameColumn, LastNameColumn, LastUpdateColumn}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/table/category.go b/examples/quick-start/.gen/jetdb/dvds/table/category.go index 8e42de9..6b34fdf 100644 --- a/examples/quick-start/.gen/jetdb/dvds/table/category.go +++ b/examples/quick-start/.gen/jetdb/dvds/table/category.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var Category = newCategoryTable() -type CategoryTable struct { +type categoryTable struct { postgres.Table //Columns @@ -26,31 +25,44 @@ type CategoryTable struct { MutableColumns postgres.ColumnList } -// creates new CategoryTable with assigned alias +type CategoryTable struct { + categoryTable + + EXCLUDED categoryTable +} + +// AS creates new CategoryTable with assigned alias func (a *CategoryTable) AS(alias string) *CategoryTable { aliasTable := newCategoryTable() - aliasTable.Table.AS(alias) - return aliasTable } func newCategoryTable() *CategoryTable { + return &CategoryTable{ + categoryTable: newCategoryTableImpl("dvds", "category"), + EXCLUDED: newCategoryTableImpl("", "excluded"), + } +} + +func newCategoryTableImpl(schemaName, tableName string) categoryTable { var ( CategoryIDColumn = postgres.IntegerColumn("category_id") NameColumn = postgres.StringColumn("name") LastUpdateColumn = postgres.TimestampColumn("last_update") + allColumns = postgres.ColumnList{CategoryIDColumn, NameColumn, LastUpdateColumn} + mutableColumns = postgres.ColumnList{NameColumn, LastUpdateColumn} ) - return &CategoryTable{ - Table: postgres.NewTable("dvds", "category", CategoryIDColumn, NameColumn, LastUpdateColumn), + return categoryTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns CategoryID: CategoryIDColumn, Name: NameColumn, LastUpdate: LastUpdateColumn, - AllColumns: postgres.ColumnList{CategoryIDColumn, NameColumn, LastUpdateColumn}, - MutableColumns: postgres.ColumnList{NameColumn, LastUpdateColumn}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/table/film.go b/examples/quick-start/.gen/jetdb/dvds/table/film.go index 6c8a8c2..3550465 100644 --- a/examples/quick-start/.gen/jetdb/dvds/table/film.go +++ b/examples/quick-start/.gen/jetdb/dvds/table/film.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var Film = newFilmTable() -type FilmTable struct { +type filmTable struct { postgres.Table //Columns @@ -36,16 +35,27 @@ type FilmTable struct { MutableColumns postgres.ColumnList } -// creates new FilmTable with assigned alias +type FilmTable struct { + filmTable + + EXCLUDED filmTable +} + +// AS creates new FilmTable with assigned alias func (a *FilmTable) AS(alias string) *FilmTable { aliasTable := newFilmTable() - aliasTable.Table.AS(alias) - return aliasTable } func newFilmTable() *FilmTable { + return &FilmTable{ + filmTable: newFilmTableImpl("dvds", "film"), + EXCLUDED: newFilmTableImpl("", "excluded"), + } +} + +func newFilmTableImpl(schemaName, tableName string) filmTable { var ( FilmIDColumn = postgres.IntegerColumn("film_id") TitleColumn = postgres.StringColumn("title") @@ -60,10 +70,12 @@ func newFilmTable() *FilmTable { LastUpdateColumn = postgres.TimestampColumn("last_update") SpecialFeaturesColumn = postgres.StringColumn("special_features") FulltextColumn = postgres.StringColumn("fulltext") + 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} ) - return &FilmTable{ - Table: postgres.NewTable("dvds", "film", FilmIDColumn, TitleColumn, DescriptionColumn, ReleaseYearColumn, LanguageIDColumn, RentalDurationColumn, RentalRateColumn, LengthColumn, ReplacementCostColumn, RatingColumn, LastUpdateColumn, SpecialFeaturesColumn, FulltextColumn), + return filmTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns FilmID: FilmIDColumn, @@ -80,7 +92,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: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/table/film_actor.go b/examples/quick-start/.gen/jetdb/dvds/table/film_actor.go index b30e524..89622ec 100644 --- a/examples/quick-start/.gen/jetdb/dvds/table/film_actor.go +++ b/examples/quick-start/.gen/jetdb/dvds/table/film_actor.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var FilmActor = newFilmActorTable() -type FilmActorTable struct { +type filmActorTable struct { postgres.Table //Columns @@ -26,31 +25,44 @@ type FilmActorTable struct { MutableColumns postgres.ColumnList } -// creates new FilmActorTable with assigned alias +type FilmActorTable struct { + filmActorTable + + EXCLUDED filmActorTable +} + +// AS creates new FilmActorTable with assigned alias func (a *FilmActorTable) AS(alias string) *FilmActorTable { aliasTable := newFilmActorTable() - aliasTable.Table.AS(alias) - return aliasTable } func newFilmActorTable() *FilmActorTable { + return &FilmActorTable{ + filmActorTable: newFilmActorTableImpl("dvds", "film_actor"), + EXCLUDED: newFilmActorTableImpl("", "excluded"), + } +} + +func newFilmActorTableImpl(schemaName, tableName string) filmActorTable { var ( ActorIDColumn = postgres.IntegerColumn("actor_id") FilmIDColumn = postgres.IntegerColumn("film_id") LastUpdateColumn = postgres.TimestampColumn("last_update") + allColumns = postgres.ColumnList{ActorIDColumn, FilmIDColumn, LastUpdateColumn} + mutableColumns = postgres.ColumnList{LastUpdateColumn} ) - return &FilmActorTable{ - Table: postgres.NewTable("dvds", "film_actor", ActorIDColumn, FilmIDColumn, LastUpdateColumn), + return filmActorTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns ActorID: ActorIDColumn, FilmID: FilmIDColumn, LastUpdate: LastUpdateColumn, - AllColumns: postgres.ColumnList{ActorIDColumn, FilmIDColumn, LastUpdateColumn}, - MutableColumns: postgres.ColumnList{LastUpdateColumn}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/table/film_category.go b/examples/quick-start/.gen/jetdb/dvds/table/film_category.go index 3605fe1..eb932c4 100644 --- a/examples/quick-start/.gen/jetdb/dvds/table/film_category.go +++ b/examples/quick-start/.gen/jetdb/dvds/table/film_category.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var FilmCategory = newFilmCategoryTable() -type FilmCategoryTable struct { +type filmCategoryTable struct { postgres.Table //Columns @@ -26,31 +25,44 @@ type FilmCategoryTable struct { MutableColumns postgres.ColumnList } -// creates new FilmCategoryTable with assigned alias +type FilmCategoryTable struct { + filmCategoryTable + + EXCLUDED filmCategoryTable +} + +// AS creates new FilmCategoryTable with assigned alias func (a *FilmCategoryTable) AS(alias string) *FilmCategoryTable { aliasTable := newFilmCategoryTable() - aliasTable.Table.AS(alias) - return aliasTable } func newFilmCategoryTable() *FilmCategoryTable { + return &FilmCategoryTable{ + filmCategoryTable: newFilmCategoryTableImpl("dvds", "film_category"), + EXCLUDED: newFilmCategoryTableImpl("", "excluded"), + } +} + +func newFilmCategoryTableImpl(schemaName, tableName string) filmCategoryTable { var ( FilmIDColumn = postgres.IntegerColumn("film_id") CategoryIDColumn = postgres.IntegerColumn("category_id") LastUpdateColumn = postgres.TimestampColumn("last_update") + allColumns = postgres.ColumnList{FilmIDColumn, CategoryIDColumn, LastUpdateColumn} + mutableColumns = postgres.ColumnList{LastUpdateColumn} ) - return &FilmCategoryTable{ - Table: postgres.NewTable("dvds", "film_category", FilmIDColumn, CategoryIDColumn, LastUpdateColumn), + return filmCategoryTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns FilmID: FilmIDColumn, CategoryID: CategoryIDColumn, LastUpdate: LastUpdateColumn, - AllColumns: postgres.ColumnList{FilmIDColumn, CategoryIDColumn, LastUpdateColumn}, - MutableColumns: postgres.ColumnList{LastUpdateColumn}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/table/language.go b/examples/quick-start/.gen/jetdb/dvds/table/language.go index db8f513..c68a6ce 100644 --- a/examples/quick-start/.gen/jetdb/dvds/table/language.go +++ b/examples/quick-start/.gen/jetdb/dvds/table/language.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var Language = newLanguageTable() -type LanguageTable struct { +type languageTable struct { postgres.Table //Columns @@ -26,31 +25,44 @@ type LanguageTable struct { MutableColumns postgres.ColumnList } -// creates new LanguageTable with assigned alias +type LanguageTable struct { + languageTable + + EXCLUDED languageTable +} + +// AS creates new LanguageTable with assigned alias func (a *LanguageTable) AS(alias string) *LanguageTable { aliasTable := newLanguageTable() - aliasTable.Table.AS(alias) - return aliasTable } func newLanguageTable() *LanguageTable { + return &LanguageTable{ + languageTable: newLanguageTableImpl("dvds", "language"), + EXCLUDED: newLanguageTableImpl("", "excluded"), + } +} + +func newLanguageTableImpl(schemaName, tableName string) languageTable { var ( LanguageIDColumn = postgres.IntegerColumn("language_id") NameColumn = postgres.StringColumn("name") LastUpdateColumn = postgres.TimestampColumn("last_update") + allColumns = postgres.ColumnList{LanguageIDColumn, NameColumn, LastUpdateColumn} + mutableColumns = postgres.ColumnList{NameColumn, LastUpdateColumn} ) - return &LanguageTable{ - Table: postgres.NewTable("dvds", "language", LanguageIDColumn, NameColumn, LastUpdateColumn), + return languageTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns LanguageID: LanguageIDColumn, Name: NameColumn, LastUpdate: LastUpdateColumn, - AllColumns: postgres.ColumnList{LanguageIDColumn, NameColumn, LastUpdateColumn}, - MutableColumns: postgres.ColumnList{NameColumn, LastUpdateColumn}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/view/actor_info.go b/examples/quick-start/.gen/jetdb/dvds/view/actor_info.go index 697966d..21e901a 100644 --- a/examples/quick-start/.gen/jetdb/dvds/view/actor_info.go +++ b/examples/quick-start/.gen/jetdb/dvds/view/actor_info.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var ActorInfo = newActorInfoTable() -type ActorInfoTable struct { +type actorInfoTable struct { postgres.Table //Columns @@ -27,25 +26,38 @@ type ActorInfoTable struct { MutableColumns postgres.ColumnList } -// creates new ActorInfoTable with assigned alias +type ActorInfoTable struct { + actorInfoTable + + EXCLUDED actorInfoTable +} + +// AS creates new ActorInfoTable with assigned alias func (a *ActorInfoTable) AS(alias string) *ActorInfoTable { aliasTable := newActorInfoTable() - aliasTable.Table.AS(alias) - return aliasTable } func newActorInfoTable() *ActorInfoTable { + return &ActorInfoTable{ + actorInfoTable: newActorInfoTableImpl("dvds", "actor_info"), + EXCLUDED: newActorInfoTableImpl("", "excluded"), + } +} + +func newActorInfoTableImpl(schemaName, tableName string) actorInfoTable { var ( ActorIDColumn = postgres.IntegerColumn("actor_id") FirstNameColumn = postgres.StringColumn("first_name") LastNameColumn = postgres.StringColumn("last_name") FilmInfoColumn = postgres.StringColumn("film_info") + allColumns = postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn} + mutableColumns = postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn} ) - return &ActorInfoTable{ - Table: postgres.NewTable("dvds", "actor_info", ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn), + return actorInfoTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns ActorID: ActorIDColumn, @@ -53,7 +65,7 @@ func newActorInfoTable() *ActorInfoTable { LastName: LastNameColumn, FilmInfo: FilmInfoColumn, - AllColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn}, - MutableColumns: postgres.ColumnList{ActorIDColumn, FirstNameColumn, LastNameColumn, FilmInfoColumn}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/.gen/jetdb/dvds/view/customer_list.go b/examples/quick-start/.gen/jetdb/dvds/view/customer_list.go index 4766158..08b45d1 100644 --- a/examples/quick-start/.gen/jetdb/dvds/view/customer_list.go +++ b/examples/quick-start/.gen/jetdb/dvds/view/customer_list.go @@ -1,6 +1,5 @@ // // 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 @@ -14,7 +13,7 @@ import ( var CustomerList = newCustomerListTable() -type CustomerListTable struct { +type customerListTable struct { postgres.Table //Columns @@ -32,30 +31,43 @@ type CustomerListTable struct { MutableColumns postgres.ColumnList } -// creates new CustomerListTable with assigned alias +type CustomerListTable struct { + customerListTable + + EXCLUDED customerListTable +} + +// AS creates new CustomerListTable with assigned alias func (a *CustomerListTable) AS(alias string) *CustomerListTable { aliasTable := newCustomerListTable() - aliasTable.Table.AS(alias) - return aliasTable } func newCustomerListTable() *CustomerListTable { + return &CustomerListTable{ + customerListTable: newCustomerListTableImpl("dvds", "customer_list"), + EXCLUDED: newCustomerListTableImpl("", "excluded"), + } +} + +func newCustomerListTableImpl(schemaName, tableName string) 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") + 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") + allColumns = postgres.ColumnList{IDColumn, NameColumn, AddressColumn, ZipCodeColumn, PhoneColumn, CityColumn, CountryColumn, NotesColumn, SidColumn} + mutableColumns = postgres.ColumnList{IDColumn, NameColumn, AddressColumn, ZipCodeColumn, PhoneColumn, CityColumn, CountryColumn, NotesColumn, SidColumn} ) - return &CustomerListTable{ - Table: postgres.NewTable("dvds", "customer_list", IDColumn, NameColumn, AddressColumn, ZipCodeColumn, PhoneColumn, CityColumn, CountryColumn, NotesColumn, SidColumn), + return customerListTable{ + Table: postgres.NewTable(schemaName, tableName, allColumns...), //Columns ID: IDColumn, @@ -68,7 +80,7 @@ func newCustomerListTable() *CustomerListTable { 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}, + AllColumns: allColumns, + MutableColumns: mutableColumns, } } diff --git a/examples/quick-start/README.md b/examples/quick-start/README.md index 0417515..2e5adc5 100644 --- a/examples/quick-start/README.md +++ b/examples/quick-start/README.md @@ -3,10 +3,10 @@ This package contains sample usage for Jet framework. -Jet generated files of interest are in ./gen folder. +Jet generated files of interest are in `./gen` folder. -quick-start.go contains code explained at [README.md](../../README.md#quick-start), -with difference of redirecting json output to files(dest.json and dest2.json) rather then to a +`quick-start.go` - contains code explained at main [README.md](../../README.md#quick-start), +with a difference of redirecting json output to files(`dest.json` and `dest2.json`) rather then to a standard output. -./gen, dest.json and dest2.json - added to git for presentation purposes. +`./gen`, `dest.json` and `dest2.json` - added to git for presentation purposes. diff --git a/examples/quick-start/quick-start.go b/examples/quick-start/quick-start.go index 0fe031a..693edf7 100644 --- a/examples/quick-start/quick-start.go +++ b/examples/quick-start/quick-start.go @@ -7,7 +7,7 @@ import ( _ "github.com/lib/pq" "io/ioutil" - // dot import so go code would resemble as much as native SQL + // dot import so that jet go code would resemble as much as native SQL // dot import is not mandatory . "github.com/go-jet/jet/examples/quick-start/.gen/jetdb/dvds/table" . "github.com/go-jet/jet/postgres" @@ -98,15 +98,15 @@ func printStatementInfo(stmt SelectStatement) { query, args := stmt.Sql() fmt.Println("Parameterized query: ") + fmt.Println("==============================") fmt.Println(query) fmt.Println("Arguments: ") fmt.Println(args) debugSQL := stmt.DebugSql() - fmt.Println("\n\n==============================") - fmt.Println("\n\nDebug sql: ") + fmt.Println("==============================") fmt.Println(debugSQL) }