diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-05-15 03:17:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-14 20:17:06 +0100 |
commit | f6be429781b24b1ac3b6e719b9c64df33866db93 (patch) | |
tree | dec0c6c9fb4f4d146f76b96f463a448494bcd010 /vendor/xorm.io/xorm/dialects/driver.go | |
parent | e2f39c2b64e1c5360702e507e0cac56255ca61c3 (diff) | |
download | gitea-f6be429781b24b1ac3b6e719b9c64df33866db93.tar.gz gitea-f6be429781b24b1ac3b6e719b9c64df33866db93.zip |
Upgrade xorm to v1.1.0 (#15869)
Diffstat (limited to 'vendor/xorm.io/xorm/dialects/driver.go')
-rw-r--r-- | vendor/xorm.io/xorm/dialects/driver.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/vendor/xorm.io/xorm/dialects/driver.go b/vendor/xorm.io/xorm/dialects/driver.go index ae3afe4254..bb46a9368e 100644 --- a/vendor/xorm.io/xorm/dialects/driver.go +++ b/vendor/xorm.io/xorm/dialects/driver.go @@ -8,6 +8,7 @@ import ( "fmt" ) +// Driver represents a database driver type Driver interface { Parse(string, string) (*URI, error) } @@ -16,6 +17,7 @@ var ( drivers = map[string]Driver{} ) +// RegisterDriver register a driver func RegisterDriver(driverName string, driver Driver) { if driver == nil { panic("core: Register driver is nil") @@ -26,10 +28,12 @@ func RegisterDriver(driverName string, driver Driver) { drivers[driverName] = driver } +// QueryDriver query a driver with name func QueryDriver(driverName string) Driver { return drivers[driverName] } +// RegisteredDriverSize returned all drivers's length func RegisteredDriverSize() int { return len(drivers) } @@ -38,7 +42,7 @@ func RegisteredDriverSize() int { func OpenDialect(driverName, connstr string) (Dialect, error) { driver := QueryDriver(driverName) if driver == nil { - return nil, fmt.Errorf("Unsupported driver name: %v", driverName) + return nil, fmt.Errorf("unsupported driver name: %v", driverName) } uri, err := driver.Parse(driverName, connstr) @@ -48,7 +52,7 @@ func OpenDialect(driverName, connstr string) (Dialect, error) { dialect := QueryDialect(uri.DBType) if dialect == nil { - return nil, fmt.Errorf("Unsupported dialect type: %v", uri.DBType) + return nil, fmt.Errorf("unsupported dialect type: %v", uri.DBType) } dialect.Init(uri) |