diff --git a/generator/template/process.go b/generator/template/process.go index eb10f60..01ba1b1 100644 --- a/generator/template/process.go +++ b/generator/template/process.go @@ -71,16 +71,20 @@ func processTableSQLBuilderSetSchema(dirPath string, schemaMetadata metadata.Sch return } - fmt.Println("Generating global `SetSchema` method...") - err := utils.EnsureDirPath(dirPath) throw.OnError(err) var builders []TableSQLBuilder for _, tm := range schemaMetadata.TablesMetaData { - builders = append(builders, builderTemplate.Table(tm)) + table := builderTemplate.Table(tm) + builders = append(builders, table) + + if table.Skip { + return + } } + fmt.Println("Generating global `SetSchema` method...") schemaIdentifier := utils.ToGoIdentifier(schemaMetadata.Name) funcPath := path.Join(dirPath, builders[0].Path) diff --git a/tests/postgres/generator_test.go b/tests/postgres/generator_test.go index 328de17..0824103 100644 --- a/tests/postgres/generator_test.go +++ b/tests/postgres/generator_test.go @@ -10,10 +10,11 @@ import ( "strconv" "testing" + "github.com/stretchr/testify/require" + "github.com/go-jet/jet/v2/generator/postgres" "github.com/go-jet/jet/v2/internal/testutils" "github.com/go-jet/jet/v2/tests/dbconfig" - "github.com/stretchr/testify/require" "github.com/go-jet/jet/v2/tests/.gentestdata/jetdb/dvds/model" ) @@ -913,4 +914,15 @@ func newAllTypesTableImpl(schemaName, tableName, alias string) allTypesTable { MutableColumns: mutableColumns, } } + +func SetTestSampleSchema(schema string) { + AllTypes = AllTypes.FromSchema(schema) + Link = Link.FromSchema(schema) + Employee = Employee.FromSchema(schema) + Person = Person.FromSchema(schema) + PersonPhone = PersonPhone.FromSchema(schema) + WeirdNamesTable = WeirdNamesTable.FromSchema(schema) + User = User.FromSchema(schema) + Floats = Floats.FromSchema(schema) +} ` diff --git a/tests/sqlite/generator_test.go b/tests/sqlite/generator_test.go index 9665387..9b711a3 100644 --- a/tests/sqlite/generator_test.go +++ b/tests/sqlite/generator_test.go @@ -7,11 +7,12 @@ import ( "reflect" "testing" + "github.com/stretchr/testify/require" + "github.com/go-jet/jet/v2/generator/sqlite" "github.com/go-jet/jet/v2/internal/testutils" "github.com/go-jet/jet/v2/tests/.gentestdata/sqlite/sakila/model" "github.com/go-jet/jet/v2/tests/internal/utils/repo" - "github.com/stretchr/testify/require" ) func TestGeneratedModel(t *testing.T) { @@ -224,6 +225,25 @@ func newActorTableImpl(schemaName, tableName, alias string) actorTable { MutableColumns: mutableColumns, } } + +func SetSchema(schema string) { + Actor = Actor.FromSchema(schema) + Address = Address.FromSchema(schema) + Category = Category.FromSchema(schema) + City = City.FromSchema(schema) + Country = Country.FromSchema(schema) + Customer = Customer.FromSchema(schema) + Film = Film.FromSchema(schema) + FilmActor = FilmActor.FromSchema(schema) + FilmCategory = FilmCategory.FromSchema(schema) + FilmText = FilmText.FromSchema(schema) + Inventory = Inventory.FromSchema(schema) + Language = Language.FromSchema(schema) + Payment = Payment.FromSchema(schema) + Rental = Rental.FromSchema(schema) + Staff = Staff.FromSchema(schema) + Store = Store.FromSchema(schema) +} ` const filmListSQLBuilderFile = `