Skip to content

Commit

Permalink
format code (zeromicro#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan authored Aug 9, 2021
1 parent a74aaf1 commit 02adccc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tools/goctl/model/sql/builderx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func RawFieldNames(in interface{}, postgresSql ...bool) []string {
}

func PostgreSqlJoin(elems []string) string {
var b = new(strings.Builder)
b := new(strings.Builder)
for index, e := range elems {
b.WriteString(fmt.Sprintf("%s = $%d, ", e, index+1))
}
Expand Down
2 changes: 1 addition & 1 deletion tools/goctl/model/sql/gen/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func genCacheKeys(table parser.Table) (Key, []Key) {
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 (
varLeftJoin, varRightJon, fieldNameJoin Join
varLeft, varRight, varExpression string
Expand Down
20 changes: 9 additions & 11 deletions tools/goctl/model/sql/model/postgresqlmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import (
"github.com/tal-tech/go-zero/core/stores/sqlx"
)

var (
p2m = map[string]string{
"int8": "bigint",
"numeric": "bigint",
"float8": "double",
"float4": "float",
"int2": "smallint",
"int4": "integer",
}
)
var p2m = map[string]string{
"int8": "bigint",
"numeric": "bigint",
"float8": "double",
"float4": "float",
"int2": "smallint",
"int4": "integer",
}

// PostgreSqlModel gets table information from information_schema、pg_catalog
type PostgreSqlModel struct {
Expand Down Expand Up @@ -173,7 +171,7 @@ func (m *PostgreSqlModel) getIndex(schema, table string) (map[string][]*DbIndex,
if err != nil {
return nil, err
}
var index = make(map[string][]*DbIndex)
index := make(map[string][]*DbIndex)
for _, e := range indexes {
if e.IsPrimary.Bool {
index[e.ColumnName.String] = append(index[e.ColumnName.String], &DbIndex{
Expand Down
4 changes: 2 additions & 2 deletions tools/goctl/model/sql/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type (
)

// Parse parses ddl into golang structure
func Parse(filename string, database string) ([]*Table, error) {
func Parse(filename, database string) ([]*Table, error) {
p := parser.NewParser()
tables, err := p.From(filename)
if err != nil {
Expand Down Expand Up @@ -146,7 +146,7 @@ func Parse(filename string, database string) ([]*Table, error) {

list = append(list, &Table{
Name: stringx.From(e.Name),
Db: stringx.From(database),
Db: stringx.From(database),
PrimaryKey: primaryKey,
UniqueIndex: uniqueIndex,
Fields: fields,
Expand Down

0 comments on commit 02adccc

Please sign in to comment.