Add pgx dialect for github.com/jackc/pgx
This commit is contained in:
parent
0a51f6cdc5
commit
8909aa382b
@ -7,7 +7,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBelongsTo(t *testing.T) {
|
func TestBelongsTo(t *testing.T) {
|
||||||
|
@ -3,7 +3,7 @@ package gorm_test
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -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
13
dialect_pgx.go
Normal 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
3
dialects/pgx/pgx.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package pgx
|
||||||
|
|
||||||
|
import _ "github.com/jackc/pgx/stdlib"
|
@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestErrorsCanBeUsedOutsideGorm(t *testing.T) {
|
func TestErrorsCanBeUsedOutsideGorm(t *testing.T) {
|
||||||
|
@ -3,7 +3,7 @@ package gorm_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CalculateField struct {
|
type CalculateField struct {
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Person struct {
|
type Person struct {
|
||||||
|
18
main_test.go
18
main_test.go
@ -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")
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getPreloadUser(name string) *User {
|
func getPreloadUser(name string) *User {
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestScannableSlices(t *testing.T) {
|
func TestScannableSlices(t *testing.T) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package gorm_test
|
package gorm_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUpdate(t *testing.T) {
|
func TestUpdate(t *testing.T) {
|
||||||
|
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user