CONNSTRING

同时兼容
postgresql和postgres
This commit is contained in:
TossPig 2015-11-26 16:47:40 +08:00
parent a3e2e73b65
commit 1aa62881bb
1 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,7 @@ func parseURL(connstr string) (string, error) {
return "", err
}
if u.Scheme != "postgresql" {
if u.Scheme != "postgresql" && u.Scheme != "postgres" {
return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme)
}
@ -103,7 +103,7 @@ func (p *pqDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
db := &core.Uri{DbType: core.POSTGRES}
o := make(values)
var err error
if strings.HasPrefix(dataSourceName, "postgresql://") {
if strings.HasPrefix(dataSourceName, "postgresql://") || strings.HasPrefix(dataSourceName, "postgres://") {
dataSourceName, err = parseURL(dataSourceName)
if err != nil {
return nil, err