Add the ability to fully customize jet generated files.
This commit is contained in:
parent
caa81930dc
commit
8864667f47
40 changed files with 2274 additions and 882 deletions
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/go-jet/jet/v2/generator/mysql"
|
||||
"github.com/go-jet/jet/v2/generator/postgres"
|
||||
"github.com/go-jet/jet/v2/internal/utils"
|
||||
"github.com/go-jet/jet/v2/internal/utils/throw"
|
||||
"github.com/go-jet/jet/v2/tests/dbconfig"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/lib/pq"
|
||||
|
|
@ -62,7 +62,7 @@ func initMySQLDB() {
|
|||
cmd.Stdout = os.Stdout
|
||||
|
||||
err := cmd.Run()
|
||||
utils.PanicOnError(err)
|
||||
throw.OnError(err)
|
||||
|
||||
err = mysql.Generate("./.gentestdata/mysql", mysql.DBConnection{
|
||||
Host: dbconfig.MySqLHost,
|
||||
|
|
@ -72,7 +72,7 @@ func initMySQLDB() {
|
|||
DBName: dbName,
|
||||
})
|
||||
|
||||
utils.PanicOnError(err)
|
||||
throw.OnError(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -99,24 +99,24 @@ func initPostgresDB() {
|
|||
execFile(db, "./testdata/init/postgres/"+schemaName+".sql")
|
||||
|
||||
err = postgres.Generate("./.gentestdata", postgres.DBConnection{
|
||||
Host: dbconfig.Host,
|
||||
Host: dbconfig.PgHost,
|
||||
Port: 5432,
|
||||
User: dbconfig.User,
|
||||
Password: dbconfig.Password,
|
||||
DBName: dbconfig.DBName,
|
||||
User: dbconfig.PgUser,
|
||||
Password: dbconfig.PgPassword,
|
||||
DBName: dbconfig.PgDBName,
|
||||
SchemaName: schemaName,
|
||||
SslMode: "disable",
|
||||
})
|
||||
utils.PanicOnError(err)
|
||||
throw.OnError(err)
|
||||
}
|
||||
}
|
||||
|
||||
func execFile(db *sql.DB, sqlFilePath string) {
|
||||
testSampleSql, err := ioutil.ReadFile(sqlFilePath)
|
||||
utils.PanicOnError(err)
|
||||
throw.OnError(err)
|
||||
|
||||
_, err = db.Exec(string(testSampleSql))
|
||||
utils.PanicOnError(err)
|
||||
throw.OnError(err)
|
||||
}
|
||||
|
||||
func printOnError(err error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue