mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
format code (#884)
This commit is contained in:
parent
a74aaf1823
commit
02adcccbf4
@ -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))
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
@ -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{
|
||||
|
@ -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 {
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user