add go report badge
This commit is contained in:
@@ -381,7 +381,7 @@ func TestRedis_SortedSet(t *testing.T) {
|
|||||||
rank, err := client.Zrank("key", "value2")
|
rank, err := client.Zrank("key", "value2")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, int64(1), rank)
|
assert.Equal(t, int64(1), rank)
|
||||||
rank, err = client.Zrank("key", "value4")
|
_, err = client.Zrank("key", "value4")
|
||||||
assert.Equal(t, redis.Nil, err)
|
assert.Equal(t, redis.Nil, err)
|
||||||
num, err := client.Zrem("key", "value2", "value3")
|
num, err := client.Zrem("key", "value2", "value3")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
[](https://github.com/tal-tech/go-zero/actions)
|
[](https://github.com/tal-tech/go-zero/actions)
|
||||||
[](https://codecov.io/gh/tal-tech/go-zero)
|
[](https://codecov.io/gh/tal-tech/go-zero)
|
||||||
|
[](https://goreportcard.com/report/github.com/tal-tech/go-zero)
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
## 1. go-zero框架背景
|
## 1. go-zero框架背景
|
||||||
|
|||||||
@@ -99,8 +99,6 @@ func (s rootState) processToken(token string, annos []spec.Annotation) (state, e
|
|||||||
switch token {
|
switch token {
|
||||||
case infoDirective:
|
case infoDirective:
|
||||||
return newInfoState(s.baseState), nil
|
return newInfoState(s.baseState), nil
|
||||||
//case typeDirective:
|
|
||||||
//return newTypeState(s.baseState, annos), nil
|
|
||||||
case serviceDirective:
|
case serviceDirective:
|
||||||
return newServiceState(s.baseState, annos), nil
|
return newServiceState(s.baseState, annos), nil
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -42,14 +42,17 @@ func Parse(ddl string) (*Table, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ddlStmt, ok := stmt.(*sqlparser.DDL)
|
ddlStmt, ok := stmt.(*sqlparser.DDL)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, unSupportDDL
|
return nil, unSupportDDL
|
||||||
}
|
}
|
||||||
|
|
||||||
action := ddlStmt.Action
|
action := ddlStmt.Action
|
||||||
if action != sqlparser.CreateStr {
|
if action != sqlparser.CreateStr {
|
||||||
return nil, fmt.Errorf("expected [CREATE] action,but found: %s", action)
|
return nil, fmt.Errorf("expected [CREATE] action,but found: %s", action)
|
||||||
}
|
}
|
||||||
|
|
||||||
tableName := ddlStmt.NewName.Name.String()
|
tableName := ddlStmt.NewName.Name.String()
|
||||||
tableSpec := ddlStmt.TableSpec
|
tableSpec := ddlStmt.TableSpec
|
||||||
if tableSpec == nil {
|
if tableSpec == nil {
|
||||||
@@ -58,7 +61,6 @@ func Parse(ddl string) (*Table, error) {
|
|||||||
|
|
||||||
columns := tableSpec.Columns
|
columns := tableSpec.Columns
|
||||||
indexes := tableSpec.Indexes
|
indexes := tableSpec.Indexes
|
||||||
|
|
||||||
keyMap := make(map[string]KeyType)
|
keyMap := make(map[string]KeyType)
|
||||||
for _, index := range indexes {
|
for _, index := range indexes {
|
||||||
info := index.Info
|
info := index.Info
|
||||||
@@ -69,6 +71,7 @@ func Parse(ddl string) (*Table, error) {
|
|||||||
if len(index.Columns) > 1 {
|
if len(index.Columns) > 1 {
|
||||||
return nil, errPrimaryKey
|
return nil, errPrimaryKey
|
||||||
}
|
}
|
||||||
|
|
||||||
keyMap[index.Columns[0].Column.String()] = primary
|
keyMap[index.Columns[0].Column.String()] = primary
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -91,11 +94,9 @@ func Parse(ddl string) (*Table, error) {
|
|||||||
keyMap[columnName] = normal
|
keyMap[columnName] = normal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var (
|
|
||||||
fields []Field
|
|
||||||
primaryKey Primary
|
|
||||||
)
|
|
||||||
|
|
||||||
|
var fields []Field
|
||||||
|
var primaryKey Primary
|
||||||
for _, column := range columns {
|
for _, column := range columns {
|
||||||
if column == nil {
|
if column == nil {
|
||||||
continue
|
continue
|
||||||
@@ -108,6 +109,7 @@ func Parse(ddl string) (*Table, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var field Field
|
var field Field
|
||||||
field.Name = stringx.From(column.Name.String())
|
field.Name = stringx.From(column.Name.String())
|
||||||
field.DataBaseType = column.Type.Type
|
field.DataBaseType = column.Type.Type
|
||||||
@@ -126,10 +128,10 @@ func Parse(ddl string) (*Table, error) {
|
|||||||
}
|
}
|
||||||
fields = append(fields, field)
|
fields = append(fields, field)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Table{
|
return &Table{
|
||||||
Name: stringx.From(tableName),
|
Name: stringx.From(tableName),
|
||||||
PrimaryKey: primaryKey,
|
PrimaryKey: primaryKey,
|
||||||
Fields: fields,
|
Fields: fields,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user