From 1aa62881bb4301b039391afc326744fdeac23497 Mon Sep 17 00:00:00 2001 From: TossPig Date: Thu, 26 Nov 2015 16:47:40 +0800 Subject: [PATCH] CONNSTRING MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同时兼容 postgresql和postgres --- pq_driver.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pq_driver.go b/pq_driver.go index f665bed5..a4e26975 100644 --- a/pq_driver.go +++ b/pq_driver.go @@ -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