Update generator tests
This commit is contained in:
parent
87cc6c9e93
commit
3aca063d57
3 changed files with 76 additions and 5 deletions
|
|
@ -236,6 +236,16 @@ func (a ActorTable) FromSchema(schemaName string) ActorTable {
|
|||
return newActorTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorTable with assigned table prefix
|
||||
func (a ActorTable) WithPrefix(prefix string) ActorTable {
|
||||
return newActorTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorTable with assigned table suffix
|
||||
func (a ActorTable) WithSuffix(suffix string) ActorTable {
|
||||
return newActorTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorTable(schemaName, tableName, alias string) ActorTable {
|
||||
var (
|
||||
ActorIDColumn = mysql.IntegerColumn("actor_id")
|
||||
|
|
@ -322,6 +332,16 @@ func (a ActorInfoTable) FromSchema(schemaName string) ActorInfoTable {
|
|||
return newActorInfoTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorInfoTable with assigned table prefix
|
||||
func (a ActorInfoTable) WithPrefix(prefix string) ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorInfoTable with assigned table suffix
|
||||
func (a ActorInfoTable) WithSuffix(suffix string) ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorInfoTable(schemaName, tableName, alias string) ActorInfoTable {
|
||||
var (
|
||||
ActorIDColumn = mysql.IntegerColumn("actor_id")
|
||||
|
|
|
|||
|
|
@ -313,6 +313,16 @@ func (a ActorTable) FromSchema(schemaName string) *ActorTable {
|
|||
return newActorTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorTable with assigned table prefix
|
||||
func (a ActorTable) WithPrefix(prefix string) *ActorTable {
|
||||
return newActorTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorTable with assigned table suffix
|
||||
func (a ActorTable) WithSuffix(suffix string) *ActorTable {
|
||||
return newActorTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorTable(schemaName, tableName, alias string) *ActorTable {
|
||||
return &ActorTable{
|
||||
actorTable: newActorTableImpl(schemaName, tableName, alias),
|
||||
|
|
@ -412,6 +422,16 @@ func (a ActorInfoTable) FromSchema(schemaName string) *ActorInfoTable {
|
|||
return newActorInfoTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorInfoTable with assigned table prefix
|
||||
func (a ActorInfoTable) WithPrefix(prefix string) *ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorInfoTable with assigned table suffix
|
||||
func (a ActorInfoTable) WithSuffix(suffix string) *ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorInfoTable(schemaName, tableName, alias string) *ActorInfoTable {
|
||||
return &ActorInfoTable{
|
||||
actorInfoTable: newActorInfoTableImpl(schemaName, tableName, alias),
|
||||
|
|
@ -705,6 +725,16 @@ func (a AllTypesTable) FromSchema(schemaName string) *AllTypesTable {
|
|||
return newAllTypesTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new AllTypesTable with assigned table prefix
|
||||
func (a AllTypesTable) WithPrefix(prefix string) *AllTypesTable {
|
||||
return newAllTypesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new AllTypesTable with assigned table suffix
|
||||
func (a AllTypesTable) WithSuffix(suffix string) *AllTypesTable {
|
||||
return newAllTypesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newAllTypesTable(schemaName, tableName, alias string) *AllTypesTable {
|
||||
return &AllTypesTable{
|
||||
allTypesTable: newAllTypesTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
package sqlite
|
||||
|
||||
import (
|
||||
"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"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"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) {
|
||||
|
|
@ -183,6 +184,16 @@ func (a ActorTable) FromSchema(schemaName string) *ActorTable {
|
|||
return newActorTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorTable with assigned table prefix
|
||||
func (a ActorTable) WithPrefix(prefix string) *ActorTable {
|
||||
return newActorTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorTable with assigned table suffix
|
||||
func (a ActorTable) WithSuffix(suffix string) *ActorTable {
|
||||
return newActorTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorTable(schemaName, tableName, alias string) *ActorTable {
|
||||
return &ActorTable{
|
||||
actorTable: newActorTableImpl(schemaName, tableName, alias),
|
||||
|
|
@ -264,6 +275,16 @@ func (a FilmListTable) FromSchema(schemaName string) *FilmListTable {
|
|||
return newFilmListTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new FilmListTable with assigned table prefix
|
||||
func (a FilmListTable) WithPrefix(prefix string) *FilmListTable {
|
||||
return newFilmListTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new FilmListTable with assigned table suffix
|
||||
func (a FilmListTable) WithSuffix(suffix string) *FilmListTable {
|
||||
return newFilmListTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newFilmListTable(schemaName, tableName, alias string) *FilmListTable {
|
||||
return &FilmListTable{
|
||||
filmListTable: newFilmListTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue