Add pgx dialect for github.com/jackc/pgx

This commit is contained in:
Tung Vu 2017-11-16 11:14:17 +07:00
parent 0a51f6cdc5
commit 8909aa382b
16 changed files with 42 additions and 18 deletions

View File

@ -7,7 +7,7 @@ import (
"sort"
"testing"
"github.com/jinzhu/gorm"
"gorm"
)
func TestBelongsTo(t *testing.T) {

View File

@ -3,7 +3,7 @@ package gorm_test
import (
"errors"
"github.com/jinzhu/gorm"
"gorm"
"reflect"
"testing"

View File

@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/jinzhu/gorm"
"gorm"
)
type CustomizeColumn struct {

13
dialect_pgx.go Normal file
View File

@ -0,0 +1,13 @@
package gorm
type pgx struct {
postgres
}
func init() {
RegisterDialect("pgx", &pgx{})
}
func (pgx) GetName() string {
return "pgx"
}

3
dialects/pgx/pgx.go Normal file
View File

@ -0,0 +1,3 @@
package pgx
import _ "github.com/jackc/pgx/stdlib"

View File

@ -4,7 +4,7 @@ import (
"errors"
"testing"
"github.com/jinzhu/gorm"
"gorm"
)
func TestErrorsCanBeUsedOutsideGorm(t *testing.T) {

View File

@ -3,7 +3,7 @@ package gorm_test
import (
"testing"
"github.com/jinzhu/gorm"
"gorm"
)
type CalculateField struct {

View File

@ -6,7 +6,7 @@ import (
"testing"
"time"
"github.com/jinzhu/gorm"
"gorm"
)
type Person struct {

View File

@ -12,11 +12,12 @@ import (
"time"
"github.com/erikstmartin/go-testdb"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mssql"
_ "github.com/jinzhu/gorm/dialects/mysql"
"github.com/jinzhu/gorm/dialects/postgres"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"gorm"
_ "gorm/dialects/mssql"
_ "gorm/dialects/mysql"
"gorm/dialects/postgres"
_ "gorm/dialects/sqlite"
_ "gorm/dialects/pgx"
"github.com/jinzhu/now"
)
@ -54,6 +55,13 @@ func OpenTestConnection() (db *gorm.DB, err error) {
dbhost = fmt.Sprintf("host=%v ", dbhost)
}
db, err = gorm.Open("postgres", fmt.Sprintf("%vuser=gorm password=gorm DB.name=gorm sslmode=disable", dbhost))
case "pgx":
fmt.Println("testing pgx...")
dbhost := os.Getenv("GORM_DBHOST")
if dbhost != "" {
dbhost = fmt.Sprintf("host=%v ", dbhost)
}
db, err = gorm.Open("pgx", fmt.Sprintf("%vuser=gorm password=gorm database=gorm sslmode=disable", dbhost))
case "foundation":
fmt.Println("testing foundation...")
db, err = gorm.Open("foundation", "dbname=gorm port=15432 sslmode=disable")

View File

@ -10,7 +10,7 @@ import (
"testing"
"time"
"github.com/jinzhu/gorm"
"gorm"
)
type User struct {

View File

@ -7,7 +7,7 @@ import (
"reflect"
"testing"
"github.com/jinzhu/gorm"
"gorm"
)
func getPreloadUser(name string) *User {

View File

@ -4,7 +4,7 @@ import (
"fmt"
"reflect"
"github.com/jinzhu/gorm"
"gorm"
"testing"
"time"

View File

@ -6,7 +6,7 @@ import (
"errors"
"testing"
"github.com/jinzhu/gorm"
"gorm"
)
func TestScannableSlices(t *testing.T) {

View File

@ -1,7 +1,7 @@
package gorm_test
import (
"github.com/jinzhu/gorm"
"gorm"
"testing"
)

View File

@ -4,7 +4,7 @@ import (
"testing"
"time"
"github.com/jinzhu/gorm"
"gorm"
)
func TestUpdate(t *testing.T) {

View File

@ -3,7 +3,7 @@ package gorm_test
import (
"testing"
"github.com/jinzhu/gorm"
"gorm"
)
func TestToDBNameGenerateFriendlyName(t *testing.T) {