Merge 8909aa382b01ca48e8e115a75ed00f6f771ec6c7 into 38f96c65140f00f0b15efc495a487cfd5db510b8

This commit is contained in:
Tung Vu 2018-02-09 14:01:23 +00:00 committed by GitHub
commit c0617fff71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 42 additions and 18 deletions

View File

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

View File

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

View File

@ -4,7 +4,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/jinzhu/gorm" "gorm"
) )
type CustomizeColumn struct { 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" "errors"
"testing" "testing"
"github.com/jinzhu/gorm" "gorm"
) )
func TestErrorsCanBeUsedOutsideGorm(t *testing.T) { func TestErrorsCanBeUsedOutsideGorm(t *testing.T) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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