Store config cleanup

This commit is contained in:
Denis Arh
2022-04-23 16:34:07 +02:00
parent 8f1a953697
commit fc8589efaa
4 changed files with 1 additions and 28 deletions
-7
View File
@@ -32,9 +32,6 @@ type (
Dialect goqu.DialectWrapper
// Forces debug mode on RDBMS driver
Debug bool
// MaxOpenConns sets maximum number of open connections to the database
// defaults to same value as set in the db/sql
MaxOpenConns int
@@ -96,10 +93,6 @@ func (c *Config) MaskedDSN() string {
}
func (c *Config) SetDefaults() {
//if c.PlaceholderFormat == nil {
// c.PlaceholderFormat = squirrel.Question
//}
if c.TxMaxRetries == 0 {
c.TxMaxRetries = TxRetryHardLimit
}
@@ -31,24 +31,18 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
return
}
//cfg.PlaceholderFormat = squirrel.Question
cfg.TxRetryErrHandler = txRetryErrHandler
cfg.ErrorHandler = errorHandler
//cfg.UpsertBuilder = UpsertBuilder
//cfg.CastModuleFieldToColumnType = fieldToColumnTypeCaster
//cfg.SqlSortHandler = SqlSortHandler
if s, err = rdbms.Connect(ctx, cfg); err != nil {
return
}
// See https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_ansi
// for details
// See https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_ansi for details
if _, err = s.DB().ExecContext(ctx, "SET SESSION sql_mode = 'ANSI'"); err != nil {
return
}
//ql.QueryEncoder = &QueryEncoder{}
cfg.Upgrader = NewUpgrader(s)
return s, nil
@@ -30,21 +30,13 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
return
}
//cfg.PlaceholderFormat = squirrel.Dollar
cfg.ErrorHandler = errorHandler
//cfg.SqlFunctionHandler = sqlFunctionHandler
//cfg.ASTFormatter = sqlASTFormatter
//cfg.CastModuleFieldToColumnType = fieldToColumnTypeCaster
if s, err = rdbms.Connect(ctx, cfg); err != nil {
return
}
// s.Filters
cfg.Upgrader = NewUpgrader(s)
//ql.QueryEncoder = &QueryEncoder{}
return s, nil
}
@@ -29,16 +29,12 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
return
}
//cfg.PlaceholderFormat = squirrel.Dollar
cfg.TxRetryErrHandler = txRetryErrHandler
cfg.ErrorHandler = errorHandler
// Using transactions in SQLite causes table locking
// @todo there must be a better way to go around this
cfg.TxDisabled = true
//cfg.SqlFunctionHandler = sqlFunctionHandler
//cfg.ASTFormatter = sqlASTFormatter
//cfg.CastModuleFieldToColumnType = fieldToColumnTypeCaster
// Set to zero
// Otherwise SQLite (in-memory) disconnects
@@ -51,8 +47,6 @@ func Connect(ctx context.Context, dsn string) (_ store.Storer, err error) {
cfg.Upgrader = NewUpgrader(s)
//ql.QueryEncoder = &QueryEncoder{}
return s, nil
}