0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-16 06:51:29 +01:00
gitea/vendor/github.com/go-xorm/tidb/tidb_driver.go
Thomas Boerger b6a95a8cb3 Integrate public as bindata optionally (#293)
* 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
2016-11-30 00:26:36 +08:00

48 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
}