Open
Description
I want to access informix, sql server, postres sql in the same database resolver.
But informix is an old server and doesn't enable trasaction, I have to enable SkipDefaultTransaction in gorm.Config to avoid errors.
on the other hand, other databases are working with transactions enabled, is there a possible way to set gorm.Config to every database registered in resolver?
it's seems all resolvers are share same gorm.Config from main DB, my current code here below:
func BuildDbResolver() (*gorm.DB, error) {
mainDB, err := gorm.Open(
postgres.Open(
fmt.Sprintf(
"host=%s port=%d user=%s dbname=%s password=%s sslmode=disable",
PgErpConfig.Address,
PgErpConfig.Port,
PgErpConfig.UserName,
PgErpConfig.Name,
PgErpConfig.Password,
),
),
&gorm.Config{Logger: NewLogger()},
)
if err != nil {
return nil, fmt.Errorf("failed to connect to postgreSQL database: %v", err)
}
resolver := dbresolver.Register(dbresolver.Config{
Sources: []gorm.Dialector{ifx.Open(Ids12Config.DSN)}, // how to apply gorm.Config with SkipDefaultTransaction = 'true' to informix only?
TraceResolverMode: true,
}).Register(dbresolver.Config{
Sources: []gorm.Dialector{sqlserver.Open(EdisonConfig.DSN)},
TraceResolverMode: true,
})
mainDB.Use(resolver)
return mainDB, nil
}