Made 'SetSchema' to be generated in a dedicated file for views and tables.
This commit is contained in:
parent
199bb2a20a
commit
7db99b10bc
5 changed files with 164 additions and 72 deletions
|
|
@ -92,12 +92,12 @@ func TestCmdGeneratorIgnoreTablesViewsEnums(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
testutils.AssertFileNamesEqual(t, tableSQLBuilderFiles, "country.go",
|
||||
"customer.go", "film_actor.go", "film_category.go", "film_text.go", "inventory.go", "language.go",
|
||||
"payment.go", "staff.go")
|
||||
"payment.go", "staff.go", "table.go")
|
||||
|
||||
viewSQLBuilderFiles, err := ioutil.ReadDir(genDestDir + "/view")
|
||||
require.NoError(t, err)
|
||||
testutils.AssertFileNamesEqual(t, viewSQLBuilderFiles, "sales_by_film_category.go",
|
||||
"sales_by_store.go")
|
||||
"sales_by_store.go", "view.go")
|
||||
|
||||
modelFiles, err := ioutil.ReadDir(genDestDir + "/model")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -114,18 +114,20 @@ func assertGeneratedFiles(t *testing.T) {
|
|||
|
||||
testutils.AssertFileNamesEqual(t, tableSQLBuilderFiles, "actor.go", "address.go", "category.go", "city.go", "country.go",
|
||||
"customer.go", "film.go", "film_actor.go", "film_category.go", "film_text.go", "inventory.go", "language.go",
|
||||
"payment.go", "rental.go", "staff.go", "store.go")
|
||||
"payment.go", "rental.go", "staff.go", "store.go", "table.go")
|
||||
|
||||
testutils.AssertFileContent(t, genDestDir+"/table/actor.go", actorSQLBuilderFile)
|
||||
testutils.AssertFileContent(t, genDestDir+"/table/table.go", actorSQLBuilderTableFile)
|
||||
|
||||
// View SQL Builder files
|
||||
viewSQLBuilderFiles, err := ioutil.ReadDir(genDestDir + "/view")
|
||||
require.NoError(t, err)
|
||||
|
||||
testutils.AssertFileNamesEqual(t, viewSQLBuilderFiles, "film_list.go", "sales_by_film_category.go",
|
||||
"customer_list.go", "sales_by_store.go", "staff_list.go")
|
||||
"customer_list.go", "sales_by_store.go", "staff_list.go", "view.go")
|
||||
|
||||
testutils.AssertFileContent(t, genDestDir+"/view/film_list.go", filmListSQLBuilderFile)
|
||||
testutils.AssertFileContent(t, genDestDir+"/view/view.go", filmListSQLBuilderViewFile)
|
||||
|
||||
// Model files
|
||||
modelFiles, err := ioutil.ReadDir(genDestDir + "/model")
|
||||
|
|
@ -225,6 +227,16 @@ func newActorTableImpl(schemaName, tableName, alias string) actorTable {
|
|||
MutableColumns: mutableColumns,
|
||||
}
|
||||
}
|
||||
`
|
||||
const actorSQLBuilderTableFile = `
|
||||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package table
|
||||
|
||||
func SetSchema(schema string) {
|
||||
Actor = Actor.FromSchema(schema)
|
||||
|
|
@ -345,6 +357,25 @@ func newFilmListTableImpl(schemaName, tableName, alias string) filmListTable {
|
|||
}
|
||||
`
|
||||
|
||||
const filmListSQLBuilderViewFile = `
|
||||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package view
|
||||
|
||||
func SetSchema(schema string) {
|
||||
CustomerList = CustomerList.FromSchema(schema)
|
||||
FilmList = FilmList.FromSchema(schema)
|
||||
SalesByFilmCategory = SalesByFilmCategory.FromSchema(schema)
|
||||
SalesByStore = SalesByStore.FromSchema(schema)
|
||||
StaffList = StaffList.FromSchema(schema)
|
||||
}
|
||||
`
|
||||
|
||||
const addressModelFile = `
|
||||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue