added a check for skipping generation of table SQL builder code

This commit is contained in:
Jay 2022-12-01 15:15:35 +05:30
parent a792fe6e0a
commit 882d5562f3
3 changed files with 41 additions and 5 deletions

View file

@ -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)
}
`

View file

@ -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 = `