export tag identifier

This commit is contained in:
clannadxr 2021-02-09 11:18:37 +08:00
parent ffac8e3577
commit 7bd37d81f0
4 changed files with 19 additions and 0 deletions

View File

@ -209,6 +209,11 @@ func (engine *Engine) SetColumnMapper(mapper names.Mapper) {
engine.tagParser.SetColumnMapper(mapper) engine.tagParser.SetColumnMapper(mapper)
} }
// SetTagIdentifier set the tag identifier
func (engine *Engine) SetTagIdentifier(tagIdentifier string) {
engine.tagParser.SetIdentifier(tagIdentifier)
}
// Quote Use QuoteStr quote the string sql // Quote Use QuoteStr quote the string sql
func (engine *Engine) Quote(value string) string { func (engine *Engine) Quote(value string) string {
value = strings.TrimSpace(value) value = strings.TrimSpace(value)

View File

@ -167,6 +167,14 @@ func (eg *EngineGroup) SetMapper(mapper names.Mapper) {
} }
} }
// SetTagIdentifier set the tag identifier
func (eg *EngineGroup) SetTagIdentifier(tagIdentifier string) {
eg.Engine.SetTagIdentifier(tagIdentifier)
for i := 0; i < len(eg.slaves); i++ {
eg.slaves[i].SetTagIdentifier(tagIdentifier)
}
}
// SetMaxIdleConns set the max idle connections on pool, default is 2 // SetMaxIdleConns set the max idle connections on pool, default is 2
func (eg *EngineGroup) SetMaxIdleConns(conns int) { func (eg *EngineGroup) SetMaxIdleConns(conns int) {
eg.Engine.DB().SetMaxIdleConns(conns) eg.Engine.DB().SetMaxIdleConns(conns)

View File

@ -101,6 +101,7 @@ type EngineInterface interface {
SetCacher(string, caches.Cacher) SetCacher(string, caches.Cacher)
SetConnMaxLifetime(time.Duration) SetConnMaxLifetime(time.Duration)
SetColumnMapper(names.Mapper) SetColumnMapper(names.Mapper)
SetTagIdentifier(string)
SetDefaultCacher(caches.Cacher) SetDefaultCacher(caches.Cacher)
SetLogger(logger interface{}) SetLogger(logger interface{})
SetLogLevel(log.LogLevel) SetLogLevel(log.LogLevel)

View File

@ -63,6 +63,11 @@ func (parser *Parser) SetColumnMapper(mapper names.Mapper) {
parser.columnMapper = mapper parser.columnMapper = mapper
} }
func (parser *Parser) SetIdentifier(identifier string) {
parser.ClearCaches()
parser.identifier = identifier
}
func (parser *Parser) ParseWithCache(v reflect.Value) (*schemas.Table, error) { func (parser *Parser) ParseWithCache(v reflect.Value) (*schemas.Table, error) {
t := v.Type() t := v.Type()
tableI, ok := parser.tableCache.Load(t) tableI, ok := parser.tableCache.Load(t)