Skip to content

Commit 2f548ed

Browse files
committed
Expose postgres
1 parent d651ede commit 2f548ed

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

dialect.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ import (
1010
"github.com/ngorm/ngorm/model"
1111
)
1212

13-
type postgres struct {
13+
type Postgres struct {
1414
common.Dialect
1515
}
1616

17-
func (postgres) GetName() string {
17+
func (Postgres) GetName() string {
1818
return "postgres"
1919
}
2020

21-
func (postgres) BindVar(i int) string {
21+
func (Postgres) BindVar(i int) string {
2222
return fmt.Sprintf("$%v", i)
2323
}
2424

25-
func (postgres) DataTypeOf(field *model.StructField) (string, error) {
25+
func (Postgres) DataTypeOf(field *model.StructField) (string, error) {
2626
dataValue, sqlType, size, additionalType :=
2727
model.ParseFieldStructForDialect(field)
2828
if sqlType == "" {
@@ -87,15 +87,15 @@ func (postgres) DataTypeOf(field *model.StructField) (string, error) {
8787
return fmt.Sprintf("%v %v", sqlType, additionalType), nil
8888
}
8989

90-
func (s postgres) HasIndex(tableName string, indexName string) bool {
90+
func (s Postgres) HasIndex(tableName string, indexName string) bool {
9191
var count int
9292
s.DB.QueryRow(
9393
"SELECT count(*) FROM pg_indexes WHERE tablename = $1 AND indexname = $2",
9494
tableName, indexName).Scan(&count)
9595
return count > 0
9696
}
9797

98-
func (s postgres) HasForeignKey(tableName string, foreignKeyName string) bool {
98+
func (s Postgres) HasForeignKey(tableName string, foreignKeyName string) bool {
9999
var count int
100100
query := `
101101
SELECT Count(con.conname)
@@ -108,7 +108,7 @@ WHERE $1 :: regclass :: oid = con.conrelid
108108
return count > 0
109109
}
110110

111-
func (s postgres) HasTable(tableName string) bool {
111+
func (s Postgres) HasTable(tableName string) bool {
112112
var count int
113113
query := `
114114
SELECT Count(*)
@@ -120,7 +120,7 @@ WHERE table_name = $1
120120
return count > 0
121121
}
122122

123-
func (s postgres) HasColumn(tableName string, columnName string) bool {
123+
func (s Postgres) HasColumn(tableName string, columnName string) bool {
124124
var count int
125125
query := `
126126
SELECT Count(*)
@@ -132,16 +132,16 @@ WHERE table_name = $1
132132
return count > 0
133133
}
134134

135-
func (s postgres) CurrentDatabase() (name string) {
135+
func (s Postgres) CurrentDatabase() (name string) {
136136
s.DB.QueryRow("SELECT CURRENT_DATABASE()").Scan(&name)
137137
return
138138
}
139139

140-
func (s postgres) LastInsertIDReturningSuffix(tableName, key string) string {
140+
func (s Postgres) LastInsertIDReturningSuffix(tableName, key string) string {
141141
return fmt.Sprintf("RETURNING %v.%v", tableName, key)
142142
}
143143

144-
func (postgres) SupportLastInsertID() bool {
144+
func (Postgres) SupportLastInsertID() bool {
145145
return false
146146
}
147147

0 commit comments

Comments
 (0)