format code (#884)

master
Kevin Wan 3 years ago committed by GitHub
parent a74aaf1823
commit 02adcccbf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -122,7 +122,7 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
} }
func PostgreSqlJoin(elems []string) string { func PostgreSqlJoin(elems []string) string {
var b = new(strings.Builder) b := new(strings.Builder)
for index, e := range elems { for index, e := range elems {
b.WriteString(fmt.Sprintf("%s = $%d, ", e, index+1)) b.WriteString(fmt.Sprintf("%s = $%d, ", e, index+1))
} }

@ -50,7 +50,7 @@ func genCacheKeys(table parser.Table) (Key, []Key) {
return primaryKey, uniqueKey return primaryKey, uniqueKey
} }
func genCacheKey(db stringx.String, table stringx.String, in []*parser.Field) Key { func genCacheKey(db, table stringx.String, in []*parser.Field) Key {
var ( var (
varLeftJoin, varRightJon, fieldNameJoin Join varLeftJoin, varRightJon, fieldNameJoin Join
varLeft, varRight, varExpression string varLeft, varRight, varExpression string

@ -7,16 +7,14 @@ import (
"github.com/tal-tech/go-zero/core/stores/sqlx" "github.com/tal-tech/go-zero/core/stores/sqlx"
) )
var ( var p2m = map[string]string{
p2m = map[string]string{ "int8": "bigint",
"int8": "bigint", "numeric": "bigint",
"numeric": "bigint", "float8": "double",
"float8": "double", "float4": "float",
"float4": "float", "int2": "smallint",
"int2": "smallint", "int4": "integer",
"int4": "integer", }
}
)
// PostgreSqlModel gets table information from information_schema、pg_catalog // PostgreSqlModel gets table information from information_schema、pg_catalog
type PostgreSqlModel struct { type PostgreSqlModel struct {
@ -173,7 +171,7 @@ func (m *PostgreSqlModel) getIndex(schema, table string) (map[string][]*DbIndex,
if err != nil { if err != nil {
return nil, err return nil, err
} }
var index = make(map[string][]*DbIndex) index := make(map[string][]*DbIndex)
for _, e := range indexes { for _, e := range indexes {
if e.IsPrimary.Bool { if e.IsPrimary.Bool {
index[e.ColumnName.String] = append(index[e.ColumnName.String], &DbIndex{ index[e.ColumnName.String] = append(index[e.ColumnName.String], &DbIndex{

@ -47,7 +47,7 @@ type (
) )
// Parse parses ddl into golang structure // Parse parses ddl into golang structure
func Parse(filename string, database string) ([]*Table, error) { func Parse(filename, database string) ([]*Table, error) {
p := parser.NewParser() p := parser.NewParser()
tables, err := p.From(filename) tables, err := p.From(filename)
if err != nil { if err != nil {
@ -146,7 +146,7 @@ func Parse(filename string, database string) ([]*Table, error) {
list = append(list, &Table{ list = append(list, &Table{
Name: stringx.From(e.Name), Name: stringx.From(e.Name),
Db: stringx.From(database), Db: stringx.From(database),
PrimaryKey: primaryKey, PrimaryKey: primaryKey,
UniqueIndex: uniqueIndex, UniqueIndex: uniqueIndex,
Fields: fields, Fields: fields,

Loading…
Cancel
Save