mirror of
https://github.com/go-gitea/gitea
synced 2024-11-18 08:04:25 +00:00
b6a95a8cb3
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix
49 lines
960 B
Go
49 lines
960 B
Go
// Copyright 2015 The Xorm Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package tidb
|
|
|
|
import (
|
|
"errors"
|
|
"net/url"
|
|
"path/filepath"
|
|
|
|
"github.com/go-xorm/core"
|
|
)
|
|
|
|
var (
|
|
_ core.Dialect = (*tidb)(nil)
|
|
|
|
DBType core.DbType = "tidb"
|
|
)
|
|
|
|
func init() {
|
|
core.RegisterDriver(string(DBType), &tidbDriver{})
|
|
core.RegisterDialect(DBType, func() core.Dialect {
|
|
return &tidb{}
|
|
})
|
|
}
|
|
|
|
type tidbDriver struct {
|
|
}
|
|
|
|
func (p *tidbDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
|
|
u, err := url.Parse(dataSourceName)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if u.Scheme != "goleveldb" && u.Scheme != "memory" && u.Scheme != "boltdb" {
|
|
return nil, errors.New(u.Scheme + " is not supported yet.")
|
|
}
|
|
path := filepath.Join(u.Host, u.Path)
|
|
dbName := filepath.Clean(filepath.Base(path))
|
|
|
|
uri := &core.Uri{
|
|
DbType: DBType,
|
|
DbName: dbName,
|
|
}
|
|
|
|
return uri, nil
|
|
}
|