yjp hace 3 meses
padre
commit
90f3497496

+ 1 - 1
client/client.go

@@ -42,8 +42,8 @@ type Client interface {
 	InsertBatch(request *InsertBatchRequest) (string, error)
 	Delete(request *DeleteRequest) (string, error)
 	DeleteWhere(request *DeleteWhereRequest) (string, error)
-	DeleteBatch(request *DeleteBatchRequest) (string, error)
 	Update(request *UpdateRequest) (string, error)
+	UpdateWhere(request *UpdateWhereRequest) (string, error)
 	Replay(request *ReplayRequest) (string, error)
 	QueryByWhereAndOrderBy(request *QueryByWhereAndOrderByRequest) (string, []TableRow, int64, error)
 	CommonQuery(request *CommonQueryRequest) (string, []TableRow, int64, error)

+ 7 - 9
client/client_cmd_request.go

@@ -45,21 +45,19 @@ type DeleteWhereRequest struct {
 	UserID                string
 }
 
-type DeleteBatchRequest struct {
-	Items  []DeleteTableRowItem
-	UserID string
-}
-
-type DeleteTableRowItem struct {
+type UpdateRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	KeyValues             []map[string]string
+	KeyValues             map[string]string
+	NewTableRow           *TableRow
+	UserID                string
 }
 
-type UpdateRequest struct {
+type UpdateWhereRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	KeyValues             map[string]string
+	KeyColumns            []string
+	Where                 *Clause
 	NewTableRow           *TableRow
 	UserID                string
 }

+ 1 - 1
client/transaction.go

@@ -7,6 +7,6 @@ type Transaction interface {
 	InsertBatchTx(request *InsertBatchRequest) (string, error)
 	DeleteTx(request *DeleteRequest) (string, error)
 	DeleteWhereTx(request *DeleteWhereRequest) (string, error)
-	DeleteBatchTx(request *DeleteBatchRequest) (string, error)
 	UpdateTx(request *UpdateRequest) (string, error)
+	UpdateWhereTx(request *UpdateWhereRequest) (string, error)
 }

+ 27 - 22
dpsv1/client.go

@@ -233,28 +233,23 @@ func (c *Client) DeleteWhere(req *client.DeleteWhereRequest) (string, error) {
 	return reply.Statement, nil
 }
 
-func (c *Client) DeleteBatch(req *client.DeleteBatchRequest) (string, error) {
-	tableRowItems := make([]*request.DeleteTableRowItem, 0)
-
-	for _, reqTableItem := range req.Items {
-		items := make([]*request.DeleteItem, 0)
-		for _, reqKeyValues := range reqTableItem.KeyValues {
-			items = append(items, &request.DeleteItem{
-				KeyValues: reqKeyValues,
-			})
-		}
+func (c *Client) Update(req *client.UpdateRequest) (string, error) {
+	if req.NewTableRow == nil {
+		return "", nil
+	}
 
-		tableRowItems = append(tableRowItems, &request.DeleteTableRowItem{
-			TablePrefixWithSchema: reqTableItem.TablePrefixWithSchema,
-			Version:               reqTableItem.Version,
-			Items:                 items,
-		})
+	newTableRow, err := req.NewTableRow.ToDPSTableRow()
+	if err != nil {
+		return "", err
 	}
 
-	reply, err := c.commandServiceClient.DeleteBatch(context.Background(), &request.DeleteBatchRequest{
-		DatabaseID: c.databaseID,
-		Items:      tableRowItems,
-		UserID:     req.UserID,
+	reply, err := c.commandServiceClient.Update(context.Background(), &request.UpdateRequest{
+		DatabaseID:            c.databaseID,
+		TablePrefixWithSchema: req.TablePrefixWithSchema,
+		Version:               req.Version,
+		KeyValues:             req.KeyValues,
+		NewTableRow:           newTableRow,
+		UserID:                req.UserID,
 	})
 	if err != nil {
 		return "", err
@@ -263,21 +258,31 @@ func (c *Client) DeleteBatch(req *client.DeleteBatchRequest) (string, error) {
 	return reply.Statement, nil
 }
 
-func (c *Client) Update(req *client.UpdateRequest) (string, error) {
+func (c *Client) UpdateWhere(req *client.UpdateWhereRequest) (string, error) {
+	if req.Where == nil {
+		return "", errors.New("没有传递Where条件")
+	}
+
 	if req.NewTableRow == nil {
 		return "", nil
 	}
 
+	whereJsonBytes, err := req.Where.ToJson()
+	if err != nil {
+		return "", err
+	}
+
 	newTableRow, err := req.NewTableRow.ToDPSTableRow()
 	if err != nil {
 		return "", err
 	}
 
-	reply, err := c.commandServiceClient.Update(context.Background(), &request.UpdateRequest{
+	reply, err := c.commandServiceClient.UpdateWhere(context.Background(), &request.UpdateWhereRequest{
 		DatabaseID:            c.databaseID,
 		TablePrefixWithSchema: req.TablePrefixWithSchema,
 		Version:               req.Version,
-		KeyValues:             req.KeyValues,
+		KeyColumns:            req.KeyColumns,
+		Where:                 whereJsonBytes,
 		NewTableRow:           newTableRow,
 		UserID:                req.UserID,
 	})

+ 33 - 28
dpsv1/transaction.go

@@ -166,6 +166,10 @@ func (tx *Transaction) DeleteTx(req *client.DeleteRequest) (string, error) {
 }
 
 func (tx *Transaction) DeleteWhereTx(req *client.DeleteWhereRequest) (string, error) {
+	if req.Where == nil {
+		return "", errors.New("没有传递Where条件")
+	}
+
 	tx.client.transactionMutex.Lock()
 	defer tx.client.transactionMutex.Unlock()
 
@@ -173,10 +177,6 @@ func (tx *Transaction) DeleteWhereTx(req *client.DeleteWhereRequest) (string, er
 		return "", nil
 	}
 
-	if req.Where == nil {
-		return "", errors.New("没有传递Where条件")
-	}
-
 	var err error
 
 	defer func() {
@@ -215,7 +215,11 @@ func (tx *Transaction) DeleteWhereTx(req *client.DeleteWhereRequest) (string, er
 	return txResponse.Statement, nil
 }
 
-func (tx *Transaction) DeleteBatchTx(req *client.DeleteBatchRequest) (string, error) {
+func (tx *Transaction) UpdateTx(req *client.UpdateRequest) (string, error) {
+	if req.NewTableRow == nil {
+		return "", nil
+	}
+
 	tx.client.transactionMutex.Lock()
 	defer tx.client.transactionMutex.Unlock()
 
@@ -234,28 +238,19 @@ func (tx *Transaction) DeleteBatchTx(req *client.DeleteBatchRequest) (string, er
 		}
 	}()
 
-	tableRowItems := make([]*request.DeleteTableRowItem, 0)
-
-	for _, reqTableItem := range req.Items {
-		items := make([]*request.DeleteItem, 0)
-		for _, reqKeyValues := range reqTableItem.KeyValues {
-			items = append(items, &request.DeleteItem{
-				KeyValues: reqKeyValues,
-			})
-		}
-
-		tableRowItems = append(tableRowItems, &request.DeleteTableRowItem{
-			TablePrefixWithSchema: reqTableItem.TablePrefixWithSchema,
-			Version:               reqTableItem.Version,
-			Items:                 items,
-		})
+	reqNewTableRow, err := req.NewTableRow.ToDPSTableRow()
+	if err != nil {
+		return "", err
 	}
 
 	err = tx.stream.Send(&request.TransactionOperation{
-		Request: &request.TransactionOperation_DeleteBatchTxRequest{
-			DeleteBatchTxRequest: &request.DeleteBatchTxRequest{
-				Items:  tableRowItems,
-				UserID: req.UserID,
+		Request: &request.TransactionOperation_UpdateTxRequest{
+			UpdateTxRequest: &request.UpdateTxRequest{
+				TablePrefixWithSchema: req.TablePrefixWithSchema,
+				Version:               req.Version,
+				KeyValues:             req.KeyValues,
+				NewTableRow:           reqNewTableRow,
+				UserID:                req.UserID,
 			},
 		}})
 	if err != nil {
@@ -270,7 +265,11 @@ func (tx *Transaction) DeleteBatchTx(req *client.DeleteBatchRequest) (string, er
 	return txResponse.Statement, nil
 }
 
-func (tx *Transaction) UpdateTx(req *client.UpdateRequest) (string, error) {
+func (tx *Transaction) UpdateWhereTx(req *client.UpdateWhereRequest) (string, error) {
+	if req.Where == nil {
+		return "", errors.New("没有传递Where条件")
+	}
+
 	if req.NewTableRow == nil {
 		return "", nil
 	}
@@ -293,17 +292,23 @@ func (tx *Transaction) UpdateTx(req *client.UpdateRequest) (string, error) {
 		}
 	}()
 
+	whereJsonBytes, err := req.Where.ToJson()
+	if err != nil {
+		return "", err
+	}
+
 	reqNewTableRow, err := req.NewTableRow.ToDPSTableRow()
 	if err != nil {
 		return "", err
 	}
 
 	err = tx.stream.Send(&request.TransactionOperation{
-		Request: &request.TransactionOperation_UpdateTxRequest{
-			UpdateTxRequest: &request.UpdateTxRequest{
+		Request: &request.TransactionOperation_UpdateWhereTxRequest{
+			UpdateWhereTxRequest: &request.UpdateWhereTxRequest{
 				TablePrefixWithSchema: req.TablePrefixWithSchema,
 				Version:               req.Version,
-				KeyValues:             req.KeyValues,
+				KeyColumns:            req.KeyColumns,
+				Where:                 whereJsonBytes,
 				NewTableRow:           reqNewTableRow,
 				UserID:                req.UserID,
 			},

+ 6 - 6
instance_command.go

@@ -77,14 +77,14 @@ func DeleteWhere(req *client.DeleteWhereRequest, tx client.Transaction) error {
 	return nil
 }
 
-func DeleteBatch(req *client.DeleteBatchRequest, tx client.Transaction) error {
+func Update(req *client.UpdateRequest, tx client.Transaction) error {
 	var statement string
 	var err error
 
 	if tx == nil {
-		statement, err = dpsClient.DeleteBatch(req)
+		statement, err = dpsClient.Update(req)
 	} else {
-		statement, err = tx.DeleteBatchTx(req)
+		statement, err = tx.UpdateTx(req)
 	}
 	if err != nil {
 		return err
@@ -95,14 +95,14 @@ func DeleteBatch(req *client.DeleteBatchRequest, tx client.Transaction) error {
 	return nil
 }
 
-func Update(req *client.UpdateRequest, tx client.Transaction) error {
+func UpdateWhere(req *client.UpdateWhereRequest, tx client.Transaction) error {
 	var statement string
 	var err error
 
 	if tx == nil {
-		statement, err = dpsClient.Update(req)
+		statement, err = dpsClient.UpdateWhere(req)
 	} else {
-		statement, err = tx.UpdateTx(req)
+		statement, err = tx.UpdateWhereTx(req)
 	}
 	if err != nil {
 		return err

+ 14 - 14
pb/v1/command.pb.go

@@ -61,14 +61,14 @@ var file_v1_command_proto_rawDesc = []byte{
 	0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x57, 0x68, 0x65, 0x72, 0x65,
 	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e,
 	0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x6d,
-	0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a,
-	0x0b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x1b, 0x2e, 0x72,
-	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x61, 0x74,
-	0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x22, 0x2e, 0x72, 0x65, 0x73, 0x70,
-	0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74,
-	0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
-	0x46, 0x0a, 0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x65, 0x71, 0x75,
-	0x65, 0x73, 0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+	0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a,
+	0x06, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x16, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73,
+	0x74, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
+	0x22, 0x2e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61,
+	0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
+	0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57,
+	0x68, 0x65, 0x72, 0x65, 0x12, 0x1b, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x55,
+	0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x68, 0x65, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
 	0x74, 0x1a, 0x22, 0x2e, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6d,
 	0x6d, 0x61, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
 	0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x06, 0x52, 0x65, 0x70, 0x6c, 0x61,
@@ -88,8 +88,8 @@ var file_v1_command_proto_goTypes = []interface{}{
 	(*request.InsertBatchRequest)(nil),        // 3: request.InsertBatchRequest
 	(*request.DeleteRequest)(nil),             // 4: request.DeleteRequest
 	(*request.DeleteWhereRequest)(nil),        // 5: request.DeleteWhereRequest
-	(*request.DeleteBatchRequest)(nil),        // 6: request.DeleteBatchRequest
-	(*request.UpdateRequest)(nil),             // 7: request.UpdateRequest
+	(*request.UpdateRequest)(nil),             // 6: request.UpdateRequest
+	(*request.UpdateWhereRequest)(nil),        // 7: request.UpdateWhereRequest
 	(*request.ReplayRequest)(nil),             // 8: request.ReplayRequest
 	(*empty.Empty)(nil),                       // 9: google.protobuf.Empty
 	(*response.CommandStatementResponse)(nil), // 10: response.CommandStatementResponse
@@ -101,8 +101,8 @@ var file_v1_command_proto_depIdxs = []int32{
 	3,  // 3: v1.CommandService.InsertBatch:input_type -> request.InsertBatchRequest
 	4,  // 4: v1.CommandService.Delete:input_type -> request.DeleteRequest
 	5,  // 5: v1.CommandService.DeleteWhere:input_type -> request.DeleteWhereRequest
-	6,  // 6: v1.CommandService.DeleteBatch:input_type -> request.DeleteBatchRequest
-	7,  // 7: v1.CommandService.Update:input_type -> request.UpdateRequest
+	6,  // 6: v1.CommandService.Update:input_type -> request.UpdateRequest
+	7,  // 7: v1.CommandService.UpdateWhere:input_type -> request.UpdateWhereRequest
 	8,  // 8: v1.CommandService.Replay:input_type -> request.ReplayRequest
 	9,  // 9: v1.CommandService.AutoMigrate:output_type -> google.protobuf.Empty
 	10, // 10: v1.CommandService.Transaction:output_type -> response.CommandStatementResponse
@@ -110,8 +110,8 @@ var file_v1_command_proto_depIdxs = []int32{
 	10, // 12: v1.CommandService.InsertBatch:output_type -> response.CommandStatementResponse
 	10, // 13: v1.CommandService.Delete:output_type -> response.CommandStatementResponse
 	10, // 14: v1.CommandService.DeleteWhere:output_type -> response.CommandStatementResponse
-	10, // 15: v1.CommandService.DeleteBatch:output_type -> response.CommandStatementResponse
-	10, // 16: v1.CommandService.Update:output_type -> response.CommandStatementResponse
+	10, // 15: v1.CommandService.Update:output_type -> response.CommandStatementResponse
+	10, // 16: v1.CommandService.UpdateWhere:output_type -> response.CommandStatementResponse
 	10, // 17: v1.CommandService.Replay:output_type -> response.CommandStatementResponse
 	9,  // [9:18] is the sub-list for method output_type
 	0,  // [0:9] is the sub-list for method input_type

+ 23 - 23
pb/v1/command_grpc.pb.go

@@ -31,8 +31,8 @@ type CommandServiceClient interface {
 	InsertBatch(ctx context.Context, in *request.InsertBatchRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
 	Delete(ctx context.Context, in *request.DeleteRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
 	DeleteWhere(ctx context.Context, in *request.DeleteWhereRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
-	DeleteBatch(ctx context.Context, in *request.DeleteBatchRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
 	Update(ctx context.Context, in *request.UpdateRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
+	UpdateWhere(ctx context.Context, in *request.UpdateWhereRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
 	Replay(ctx context.Context, in *request.ReplayRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error)
 }
 
@@ -120,18 +120,18 @@ func (c *commandServiceClient) DeleteWhere(ctx context.Context, in *request.Dele
 	return out, nil
 }
 
-func (c *commandServiceClient) DeleteBatch(ctx context.Context, in *request.DeleteBatchRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error) {
+func (c *commandServiceClient) Update(ctx context.Context, in *request.UpdateRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error) {
 	out := new(response.CommandStatementResponse)
-	err := c.cc.Invoke(ctx, "/v1.CommandService/DeleteBatch", in, out, opts...)
+	err := c.cc.Invoke(ctx, "/v1.CommandService/Update", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
 	return out, nil
 }
 
-func (c *commandServiceClient) Update(ctx context.Context, in *request.UpdateRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error) {
+func (c *commandServiceClient) UpdateWhere(ctx context.Context, in *request.UpdateWhereRequest, opts ...grpc.CallOption) (*response.CommandStatementResponse, error) {
 	out := new(response.CommandStatementResponse)
-	err := c.cc.Invoke(ctx, "/v1.CommandService/Update", in, out, opts...)
+	err := c.cc.Invoke(ctx, "/v1.CommandService/UpdateWhere", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -157,8 +157,8 @@ type CommandServiceServer interface {
 	InsertBatch(context.Context, *request.InsertBatchRequest) (*response.CommandStatementResponse, error)
 	Delete(context.Context, *request.DeleteRequest) (*response.CommandStatementResponse, error)
 	DeleteWhere(context.Context, *request.DeleteWhereRequest) (*response.CommandStatementResponse, error)
-	DeleteBatch(context.Context, *request.DeleteBatchRequest) (*response.CommandStatementResponse, error)
 	Update(context.Context, *request.UpdateRequest) (*response.CommandStatementResponse, error)
+	UpdateWhere(context.Context, *request.UpdateWhereRequest) (*response.CommandStatementResponse, error)
 	Replay(context.Context, *request.ReplayRequest) (*response.CommandStatementResponse, error)
 	mustEmbedUnimplementedCommandServiceServer()
 }
@@ -185,12 +185,12 @@ func (UnimplementedCommandServiceServer) Delete(context.Context, *request.Delete
 func (UnimplementedCommandServiceServer) DeleteWhere(context.Context, *request.DeleteWhereRequest) (*response.CommandStatementResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method DeleteWhere not implemented")
 }
-func (UnimplementedCommandServiceServer) DeleteBatch(context.Context, *request.DeleteBatchRequest) (*response.CommandStatementResponse, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method DeleteBatch not implemented")
-}
 func (UnimplementedCommandServiceServer) Update(context.Context, *request.UpdateRequest) (*response.CommandStatementResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
 }
+func (UnimplementedCommandServiceServer) UpdateWhere(context.Context, *request.UpdateWhereRequest) (*response.CommandStatementResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method UpdateWhere not implemented")
+}
 func (UnimplementedCommandServiceServer) Replay(context.Context, *request.ReplayRequest) (*response.CommandStatementResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Replay not implemented")
 }
@@ -323,38 +323,38 @@ func _CommandService_DeleteWhere_Handler(srv interface{}, ctx context.Context, d
 	return interceptor(ctx, in, info, handler)
 }
 
-func _CommandService_DeleteBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(request.DeleteBatchRequest)
+func _CommandService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(request.UpdateRequest)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(CommandServiceServer).DeleteBatch(ctx, in)
+		return srv.(CommandServiceServer).Update(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/v1.CommandService/DeleteBatch",
+		FullMethod: "/v1.CommandService/Update",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(CommandServiceServer).DeleteBatch(ctx, req.(*request.DeleteBatchRequest))
+		return srv.(CommandServiceServer).Update(ctx, req.(*request.UpdateRequest))
 	}
 	return interceptor(ctx, in, info, handler)
 }
 
-func _CommandService_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(request.UpdateRequest)
+func _CommandService_UpdateWhere_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(request.UpdateWhereRequest)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(CommandServiceServer).Update(ctx, in)
+		return srv.(CommandServiceServer).UpdateWhere(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/v1.CommandService/Update",
+		FullMethod: "/v1.CommandService/UpdateWhere",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(CommandServiceServer).Update(ctx, req.(*request.UpdateRequest))
+		return srv.(CommandServiceServer).UpdateWhere(ctx, req.(*request.UpdateWhereRequest))
 	}
 	return interceptor(ctx, in, info, handler)
 }
@@ -404,14 +404,14 @@ var CommandService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "DeleteWhere",
 			Handler:    _CommandService_DeleteWhere_Handler,
 		},
-		{
-			MethodName: "DeleteBatch",
-			Handler:    _CommandService_DeleteBatch_Handler,
-		},
 		{
 			MethodName: "Update",
 			Handler:    _CommandService_Update_Handler,
 		},
+		{
+			MethodName: "UpdateWhere",
+			Handler:    _CommandService_UpdateWhere_Handler,
+		},
 		{
 			MethodName: "Replay",
 			Handler:    _CommandService_Replay_Handler,

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 324 - 370
pb/v1/request/command.pb.go


+ 34 - 45
pb/v1/request/command.validator.pb.go

@@ -106,27 +106,33 @@ func (this *DeleteWhereTxRequest) Validate() error {
 	}
 	return nil
 }
-func (this *DeleteBatchTxRequest) Validate() error {
-	if len(this.Items) < 1 {
-		return github_com_mwitkow_go_proto_validators.FieldError("Items", fmt.Errorf(`value '%v' must contain at least 1 elements`, this.Items))
+func (this *UpdateTxRequest) Validate() error {
+	if this.TablePrefixWithSchema == "" {
+		return github_com_mwitkow_go_proto_validators.FieldError("TablePrefixWithSchema", fmt.Errorf(`value '%v' must not be an empty string`, this.TablePrefixWithSchema))
 	}
-	for _, item := range this.Items {
-		if item != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("Items", err)
-			}
+	if this.Version == "" {
+		return github_com_mwitkow_go_proto_validators.FieldError("Version", fmt.Errorf(`value '%v' must not be an empty string`, this.Version))
+	}
+	// Validation of proto3 map<> fields is unsupported.
+	if this.NewTableRow != nil {
+		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.NewTableRow); err != nil {
+			return github_com_mwitkow_go_proto_validators.FieldError("NewTableRow", err)
 		}
 	}
 	return nil
 }
-func (this *UpdateTxRequest) Validate() error {
+func (this *UpdateWhereTxRequest) Validate() error {
 	if this.TablePrefixWithSchema == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("TablePrefixWithSchema", fmt.Errorf(`value '%v' must not be an empty string`, this.TablePrefixWithSchema))
 	}
 	if this.Version == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("Version", fmt.Errorf(`value '%v' must not be an empty string`, this.Version))
 	}
-	// Validation of proto3 map<> fields is unsupported.
+	for _, item := range this.KeyColumns {
+		if !(len(item) > 0) {
+			return github_com_mwitkow_go_proto_validators.FieldError("KeyColumns", fmt.Errorf(`value '%v' must have a length greater than '0'`, item))
+		}
+	}
 	if this.NewTableRow != nil {
 		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.NewTableRow); err != nil {
 			return github_com_mwitkow_go_proto_validators.FieldError("NewTableRow", err)
@@ -173,13 +179,6 @@ func (this *TransactionOperation) Validate() error {
 			}
 		}
 	}
-	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_DeleteBatchTxRequest); ok {
-		if oneOfNester.DeleteBatchTxRequest != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.DeleteBatchTxRequest); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("DeleteBatchTxRequest", err)
-			}
-		}
-	}
 	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_UpdateTxRequest); ok {
 		if oneOfNester.UpdateTxRequest != nil {
 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.UpdateTxRequest); err != nil {
@@ -187,6 +186,13 @@ func (this *TransactionOperation) Validate() error {
 			}
 		}
 	}
+	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_UpdateWhereTxRequest); ok {
+		if oneOfNester.UpdateWhereTxRequest != nil {
+			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.UpdateWhereTxRequest); err != nil {
+				return github_com_mwitkow_go_proto_validators.FieldError("UpdateWhereTxRequest", err)
+			}
+		}
+	}
 	if oneOfNester, ok := this.GetRequest().(*TransactionOperation_TransactionEndRequest); ok {
 		if oneOfNester.TransactionEndRequest != nil {
 			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(oneOfNester.TransactionEndRequest); err != nil {
@@ -285,46 +291,25 @@ func (this *DeleteWhereRequest) Validate() error {
 	}
 	return nil
 }
-func (this *DeleteBatchRequest) Validate() error {
+func (this *UpdateRequest) Validate() error {
 	if this.DatabaseID == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("DatabaseID", fmt.Errorf(`value '%v' must not be an empty string`, this.DatabaseID))
 	}
-	if len(this.Items) < 1 {
-		return github_com_mwitkow_go_proto_validators.FieldError("Items", fmt.Errorf(`value '%v' must contain at least 1 elements`, this.Items))
-	}
-	for _, item := range this.Items {
-		if item != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("Items", err)
-			}
-		}
-	}
-	return nil
-}
-func (this *DeleteTableRowItem) Validate() error {
 	if this.TablePrefixWithSchema == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("TablePrefixWithSchema", fmt.Errorf(`value '%v' must not be an empty string`, this.TablePrefixWithSchema))
 	}
 	if this.Version == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("Version", fmt.Errorf(`value '%v' must not be an empty string`, this.Version))
 	}
-	if len(this.Items) < 1 {
-		return github_com_mwitkow_go_proto_validators.FieldError("Items", fmt.Errorf(`value '%v' must contain at least 1 elements`, this.Items))
-	}
-	for _, item := range this.Items {
-		if item != nil {
-			if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
-				return github_com_mwitkow_go_proto_validators.FieldError("Items", err)
-			}
+	// Validation of proto3 map<> fields is unsupported.
+	if this.NewTableRow != nil {
+		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.NewTableRow); err != nil {
+			return github_com_mwitkow_go_proto_validators.FieldError("NewTableRow", err)
 		}
 	}
 	return nil
 }
-func (this *DeleteItem) Validate() error {
-	// Validation of proto3 map<> fields is unsupported.
-	return nil
-}
-func (this *UpdateRequest) Validate() error {
+func (this *UpdateWhereRequest) Validate() error {
 	if this.DatabaseID == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("DatabaseID", fmt.Errorf(`value '%v' must not be an empty string`, this.DatabaseID))
 	}
@@ -334,7 +319,11 @@ func (this *UpdateRequest) Validate() error {
 	if this.Version == "" {
 		return github_com_mwitkow_go_proto_validators.FieldError("Version", fmt.Errorf(`value '%v' must not be an empty string`, this.Version))
 	}
-	// Validation of proto3 map<> fields is unsupported.
+	for _, item := range this.KeyColumns {
+		if !(len(item) > 0) {
+			return github_com_mwitkow_go_proto_validators.FieldError("KeyColumns", fmt.Errorf(`value '%v' must have a length greater than '0'`, item))
+		}
+	}
 	if this.NewTableRow != nil {
 		if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.NewTableRow); err != nil {
 			return github_com_mwitkow_go_proto_validators.FieldError("NewTableRow", err)

+ 94 - 67
test/instance/instance_test.go

@@ -211,6 +211,10 @@ func TestTransactionBatch(t *testing.T) {
 	now2 := time.Now().Local()
 	tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
 
+	newName := simpleUUID()
+	newNow := time.Now().Local()
+	newTableNum := rand.New(rand.NewSource(newNow.Unix())).Intn(10)
+
 	var count int64
 	resultTableRow := client.NewTableRow()
 
@@ -271,17 +275,15 @@ func TestTransactionBatch(t *testing.T) {
 		assertEqual(now2.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
 		assertEqual(tableNum2, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
 		transaction(func(tx client.Transaction) error {
-			statement, err := tx.DeleteBatchTx(&client.DeleteBatchRequest{
-				Items: []client.DeleteTableRowItem{
-					{
-						TablePrefixWithSchema: tablePrefix,
-						Version:               "v1",
-						KeyValues: []map[string]string{
-							{"id": id1},
-							{"id": id2},
-						},
-					},
-				},
+			statement, err := tx.UpdateWhereTx(&client.UpdateWhereRequest{
+				TablePrefixWithSchema: tablePrefix,
+				Version:               "v1",
+				KeyColumns:            []string{"id"},
+				Where:                 client.NewClause().In("id", []string{id1, id2}),
+				NewTableRow: client.NewTableRow().
+					AddColumnValueString("name", newName).
+					AddColumnValueTime("time", newNow).
+					AddColumnValueInt("table_num", newTableNum),
 				UserID: "test",
 			})
 			if err != nil {
@@ -292,6 +294,40 @@ func TestTransactionBatch(t *testing.T) {
 
 			return nil
 		}).
+		queryByKeys(&client.QueryByKeysRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			KeyValues:             map[string]string{"id": id1},
+		}, resultTableRow).
+		assertEqual(id1, resultTableRow.ColumnValueString("id"), "ID不一致").
+		assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
+		assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
+		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
+		queryByKeys(&client.QueryByKeysRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			KeyValues:             map[string]string{"id": id2},
+		}, resultTableRow).
+		assertEqual(id2, resultTableRow.ColumnValueString("id"), "ID不一致").
+		assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
+		assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
+		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
+		transaction(func(tx client.Transaction) error {
+			statement, err := tx.DeleteWhereTx(&client.DeleteWhereRequest{
+				TablePrefixWithSchema: tablePrefix,
+				Version:               "v1",
+				KeyColumns:            []string{"id"},
+				Where:                 client.NewClause().In("id", []string{id1, id2}),
+				UserID:                "test",
+			})
+			if err != nil {
+				return err
+			}
+
+			fmt.Println(statement)
+
+			return nil
+		}).
 		countWhere(&client.CountWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
@@ -530,7 +566,7 @@ func TestUpdate(t *testing.T) {
 		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致")
 }
 
-func TestDelete(t *testing.T) {
+func TestUpdateWhere(t *testing.T) {
 	initClient(t, "localhost:30170", "2b78141779ee432295ca371b91c5cac7")
 	defer destroyClient(t, "2b78141779ee432295ca371b91c5cac7")
 
@@ -540,8 +576,11 @@ func TestDelete(t *testing.T) {
 	name := simpleUUID()
 	now := time.Now().Local()
 	tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
+	newName := simpleUUID()
+	newNow := time.Now().Local()
+	newTableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
 
-	var count int64
+	resultTableRow := client.NewTableRow()
 
 	newToolKit(t).
 		autoMigrate([]client.AutoMigrateItem{
@@ -562,21 +601,30 @@ func TestDelete(t *testing.T) {
 				AddColumnValueInt("table_num", tableNum),
 			UserID: "test",
 		}).
-		delete(&client.DeleteRequest{
+		updateWhere(&client.UpdateWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			KeyValues:             map[string]string{"id": id},
-			UserID:                "test",
+			KeyColumns:            []string{"id"},
+			Where:                 client.NewClause().Equal("name", name),
+			NewTableRow: client.NewTableRow().
+				AddColumnValueString("id", id).
+				AddColumnValueString("name", newName).
+				AddColumnValueTime("time", newNow).
+				AddColumnValueInt("table_num", newTableNum),
+			UserID: "test",
 		}).
-		countWhere(&client.CountWhereRequest{
+		queryByKeys(&client.QueryByKeysRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where:                 client.NewClause().Equal("id", id),
-		}, &count).
-		assertEqual(int64(0), count, "数量不一致")
+			KeyValues:             map[string]string{"id": id},
+		}, resultTableRow).
+		assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
+		assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
+		assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
+		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致")
 }
 
-func TestDeleteWhere(t *testing.T) {
+func TestDelete(t *testing.T) {
 	initClient(t, "localhost:30170", "2b78141779ee432295ca371b91c5cac7")
 	defer destroyClient(t, "2b78141779ee432295ca371b91c5cac7")
 
@@ -608,11 +656,10 @@ func TestDeleteWhere(t *testing.T) {
 				AddColumnValueInt("table_num", tableNum),
 			UserID: "test",
 		}).
-		deleteWhere(&client.DeleteWhereRequest{
+		delete(&client.DeleteRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			KeyColumns:            []string{"id"},
-			Where:                 client.NewClause().Equal("name", name),
+			KeyValues:             map[string]string{"id": id},
 			UserID:                "test",
 		}).
 		countWhere(&client.CountWhereRequest{
@@ -623,21 +670,16 @@ func TestDeleteWhere(t *testing.T) {
 		assertEqual(int64(0), count, "数量不一致")
 }
 
-func TestDeleteBatch(t *testing.T) {
+func TestDeleteWhere(t *testing.T) {
 	initClient(t, "localhost:30170", "2b78141779ee432295ca371b91c5cac7")
 	defer destroyClient(t, "2b78141779ee432295ca371b91c5cac7")
 
 	tablePrefix := "test." + simpleUUID()[0:8]
 
-	id1 := simpleUUID()
-	name1 := simpleUUID()
-	now1 := time.Now().Local()
-	tableNum1 := rand.New(rand.NewSource(now1.Unix())).Intn(10)
-
-	id2 := simpleUUID()
-	name2 := simpleUUID()
-	now2 := time.Now().Local()
-	tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
+	id := simpleUUID()
+	name := simpleUUID()
+	now := time.Now().Local()
+	tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
 
 	var count int64
 
@@ -649,43 +691,28 @@ func TestDeleteBatch(t *testing.T) {
 				TableModelDescribe:    tableModelDescribe,
 			},
 		}).
-		insertBatch(&client.InsertBatchRequest{
-			Items: []client.InsertTableRowItem{
-				{
-					TablePrefixWithSchema: tablePrefix,
-					Version:               "v1",
-					KeyColumns:            []string{"id"},
-					TableRows: []*client.TableRow{
-						client.NewTableRow().
-							AddColumnValueString("id", id1).
-							AddColumnValueString("name", name1).
-							AddColumnValueTime("time", now1).
-							AddColumnValueInt("table_num", tableNum1),
-						client.NewTableRow().
-							AddColumnValueString("id", id2).
-							AddColumnValueString("name", name2).
-							AddColumnValueTime("time", now2).
-							AddColumnValueInt("table_num", tableNum2),
-					},
-				},
-			},
-		}).
-		deleteBatch(&client.DeleteBatchRequest{
-			Items: []client.DeleteTableRowItem{
-				{
-					TablePrefixWithSchema: tablePrefix,
-					Version:               "v1",
-					KeyValues: []map[string]string{
-						{"id": id1},
-						{"id": id2},
-					},
-				},
-			},
+		insert(&client.InsertRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			KeyColumns:            []string{"id"},
+			TableRow: client.NewTableRow().
+				AddColumnValueString("id", id).
+				AddColumnValueString("name", name).
+				AddColumnValueTime("time", now).
+				AddColumnValueInt("table_num", tableNum),
 			UserID: "test",
 		}).
-		commonCount(&client.CommonCountRequest{
+		deleteWhere(&client.DeleteWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
+			KeyColumns:            []string{"id"},
+			Where:                 client.NewClause().Equal("name", name),
+			UserID:                "test",
+		}).
+		countWhere(&client.CountWhereRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			Where:                 client.NewClause().Equal("id", id),
 		}, &count).
 		assertEqual(int64(0), count, "数量不一致")
 }

+ 4 - 4
test/instance/sdk.go

@@ -83,8 +83,8 @@ func (toolKit *ToolKit) deleteWhere(req *client.DeleteWhereRequest) *ToolKit {
 	return toolKit
 }
 
-func (toolKit *ToolKit) deleteBatch(req *client.DeleteBatchRequest) *ToolKit {
-	err := dps.DeleteBatch(req, nil)
+func (toolKit *ToolKit) update(req *client.UpdateRequest) *ToolKit {
+	err := dps.Update(req, nil)
 	if err != nil {
 		toolKit.t.Fatal(err)
 	}
@@ -92,8 +92,8 @@ func (toolKit *ToolKit) deleteBatch(req *client.DeleteBatchRequest) *ToolKit {
 	return toolKit
 }
 
-func (toolKit *ToolKit) update(req *client.UpdateRequest) *ToolKit {
-	err := dps.Update(req, nil)
+func (toolKit *ToolKit) updateWhere(req *client.UpdateWhereRequest) *ToolKit {
+	err := dps.UpdateWhere(req, nil)
 	if err != nil {
 		toolKit.t.Fatal(err)
 	}

+ 4 - 4
test/v1/sdk.go

@@ -98,8 +98,8 @@ func (toolKit *ToolKit) deleteWhere(req *client.DeleteWhereRequest) *ToolKit {
 	return toolKit
 }
 
-func (toolKit *ToolKit) deleteBatch(req *client.DeleteBatchRequest) *ToolKit {
-	statement, err := clientInstance.DeleteBatch(req)
+func (toolKit *ToolKit) update(req *client.UpdateRequest) *ToolKit {
+	statement, err := clientInstance.Update(req)
 	if err != nil {
 		toolKit.t.Fatal(err)
 	}
@@ -109,8 +109,8 @@ func (toolKit *ToolKit) deleteBatch(req *client.DeleteBatchRequest) *ToolKit {
 	return toolKit
 }
 
-func (toolKit *ToolKit) update(req *client.UpdateRequest) *ToolKit {
-	statement, err := clientInstance.Update(req)
+func (toolKit *ToolKit) updateWhere(req *client.UpdateWhereRequest) *ToolKit {
+	statement, err := clientInstance.UpdateWhere(req)
 	if err != nil {
 		toolKit.t.Fatal(err)
 	}

+ 94 - 67
test/v1/v1_test.go

@@ -215,6 +215,10 @@ func TestTransactionBatch(t *testing.T) {
 	now2 := time.Now().Local()
 	tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
 
+	newName := simpleUUID()
+	newNow := time.Now().Local()
+	newTableNum := rand.New(rand.NewSource(newNow.Unix())).Intn(10)
+
 	var count int64
 	resultTableRow := client.NewTableRow()
 
@@ -277,17 +281,15 @@ func TestTransactionBatch(t *testing.T) {
 		assertEqual(now2.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
 		assertEqual(tableNum2, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
 		transaction(func(tx client.Transaction) error {
-			statement, err := tx.DeleteBatchTx(&client.DeleteBatchRequest{
-				Items: []client.DeleteTableRowItem{
-					{
-						TablePrefixWithSchema: tablePrefix,
-						Version:               "v1",
-						KeyValues: []map[string]string{
-							{"id": id1},
-							{"id": id2},
-						},
-					},
-				},
+			statement, err := tx.UpdateWhereTx(&client.UpdateWhereRequest{
+				TablePrefixWithSchema: tablePrefix,
+				Version:               "v1",
+				KeyColumns:            []string{"id"},
+				Where:                 client.NewClause().In("id", []string{id1, id2}),
+				NewTableRow: client.NewTableRow().
+					AddColumnValueString("name", newName).
+					AddColumnValueTime("time", newNow).
+					AddColumnValueInt("table_num", newTableNum),
 				UserID: "test",
 			})
 			if err != nil {
@@ -298,6 +300,40 @@ func TestTransactionBatch(t *testing.T) {
 
 			return nil
 		}).
+		queryByKeys(&client.QueryByKeysRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			KeyValues:             map[string]string{"id": id1},
+		}, resultTableRow).
+		assertEqual(id1, resultTableRow.ColumnValueString("id"), "ID不一致").
+		assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
+		assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
+		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
+		queryByKeys(&client.QueryByKeysRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			KeyValues:             map[string]string{"id": id2},
+		}, resultTableRow).
+		assertEqual(id2, resultTableRow.ColumnValueString("id"), "ID不一致").
+		assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
+		assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
+		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致").
+		transaction(func(tx client.Transaction) error {
+			statement, err := tx.DeleteWhereTx(&client.DeleteWhereRequest{
+				TablePrefixWithSchema: tablePrefix,
+				Version:               "v1",
+				KeyColumns:            []string{"id"},
+				Where:                 client.NewClause().In("id", []string{id1, id2}),
+				UserID:                "test",
+			})
+			if err != nil {
+				return err
+			}
+
+			fmt.Println(statement)
+
+			return nil
+		}).
 		countWhere(&client.CountWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
@@ -526,7 +562,7 @@ func TestUpdate(t *testing.T) {
 		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致")
 }
 
-func TestDelete(t *testing.T) {
+func TestUpdateWhere(t *testing.T) {
 	initClient(t, "localhost:30170", "2b78141779ee432295ca371b91c5cac7")
 	defer destroyClient(t, "2b78141779ee432295ca371b91c5cac7")
 
@@ -536,8 +572,11 @@ func TestDelete(t *testing.T) {
 	name := simpleUUID()
 	now := time.Now().Local()
 	tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
+	newName := simpleUUID()
+	newNow := time.Now().Local()
+	newTableNum := rand.New(rand.NewSource(newNow.Unix())).Intn(10)
 
-	var count int64
+	resultTableRow := client.NewTableRow()
 
 	newToolKit(t).
 		autoMigrate(&client.AutoMigrateRequest{
@@ -560,21 +599,30 @@ func TestDelete(t *testing.T) {
 				AddColumnValueInt("table_num", tableNum),
 			UserID: "test",
 		}).
-		delete(&client.DeleteRequest{
+		updateWhere(&client.UpdateWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			KeyValues:             map[string]string{"id": id},
-			UserID:                "test",
+			KeyColumns:            []string{"id"},
+			Where:                 client.NewClause().Equal("name", name),
+			NewTableRow: client.NewTableRow().
+				AddColumnValueString("id", id).
+				AddColumnValueString("name", newName).
+				AddColumnValueTime("time", newNow).
+				AddColumnValueInt("table_num", newTableNum),
+			UserID: "test",
 		}).
-		countWhere(&client.CountWhereRequest{
+		queryByKeys(&client.QueryByKeysRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where:                 client.NewClause().Equal("id", id),
-		}, &count).
-		assertEqual(int64(0), count, "数量不一致")
+			KeyValues:             map[string]string{"id": id},
+		}, resultTableRow).
+		assertEqual(id, resultTableRow.ColumnValueString("id"), "ID不一致").
+		assertEqual(newName, resultTableRow.ColumnValueString("name"), "名称不一致").
+		assertEqual(newNow.Unix(), resultTableRow.ColumnValueTime("time").Unix(), "时间不一致").
+		assertEqual(newTableNum, resultTableRow.ColumnValueInt("table_num"), "表数量不一致")
 }
 
-func TestDeleteWhere(t *testing.T) {
+func TestDelete(t *testing.T) {
 	initClient(t, "localhost:30170", "2b78141779ee432295ca371b91c5cac7")
 	defer destroyClient(t, "2b78141779ee432295ca371b91c5cac7")
 
@@ -608,11 +656,10 @@ func TestDeleteWhere(t *testing.T) {
 				AddColumnValueInt("table_num", tableNum),
 			UserID: "test",
 		}).
-		deleteWhere(&client.DeleteWhereRequest{
+		delete(&client.DeleteRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			KeyColumns:            []string{"id"},
-			Where:                 client.NewClause().Equal("name", name),
+			KeyValues:             map[string]string{"id": id},
 			UserID:                "test",
 		}).
 		countWhere(&client.CountWhereRequest{
@@ -623,21 +670,16 @@ func TestDeleteWhere(t *testing.T) {
 		assertEqual(int64(0), count, "数量不一致")
 }
 
-func TestDeleteBatch(t *testing.T) {
+func TestDeleteWhere(t *testing.T) {
 	initClient(t, "localhost:30170", "2b78141779ee432295ca371b91c5cac7")
 	defer destroyClient(t, "2b78141779ee432295ca371b91c5cac7")
 
 	tablePrefix := "test." + simpleUUID()[0:8]
 
-	id1 := simpleUUID()
-	name1 := simpleUUID()
-	now1 := time.Now().Local()
-	tableNum1 := rand.New(rand.NewSource(now1.Unix())).Intn(10)
-
-	id2 := simpleUUID()
-	name2 := simpleUUID()
-	now2 := time.Now().Local()
-	tableNum2 := rand.New(rand.NewSource(now2.Unix())).Intn(10)
+	id := simpleUUID()
+	name := simpleUUID()
+	now := time.Now().Local()
+	tableNum := rand.New(rand.NewSource(now.Unix())).Intn(10)
 
 	var count int64
 
@@ -651,43 +693,28 @@ func TestDeleteBatch(t *testing.T) {
 				},
 			},
 		}).
-		insertBatch(&client.InsertBatchRequest{
-			Items: []client.InsertTableRowItem{
-				{
-					TablePrefixWithSchema: tablePrefix,
-					Version:               "v1",
-					KeyColumns:            []string{"id"},
-					TableRows: []*client.TableRow{
-						client.NewTableRow().
-							AddColumnValueString("id", id1).
-							AddColumnValueString("name", name1).
-							AddColumnValueTime("time", now1).
-							AddColumnValueInt("table_num", tableNum1),
-						client.NewTableRow().
-							AddColumnValueString("id", id2).
-							AddColumnValueString("name", name2).
-							AddColumnValueTime("time", now2).
-							AddColumnValueInt("table_num", tableNum2),
-					},
-				},
-			},
-		}).
-		deleteBatch(&client.DeleteBatchRequest{
-			Items: []client.DeleteTableRowItem{
-				{
-					TablePrefixWithSchema: tablePrefix,
-					Version:               "v1",
-					KeyValues: []map[string]string{
-						{"id": id1},
-						{"id": id2},
-					},
-				},
-			},
+		insert(&client.InsertRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			KeyColumns:            []string{"id"},
+			TableRow: client.NewTableRow().
+				AddColumnValueString("id", id).
+				AddColumnValueString("name", name).
+				AddColumnValueTime("time", now).
+				AddColumnValueInt("table_num", tableNum),
 			UserID: "test",
 		}).
-		commonCount(&client.CommonCountRequest{
+		deleteWhere(&client.DeleteWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
+			KeyColumns:            []string{"id"},
+			Where:                 client.NewClause().Equal("name", name),
+			UserID:                "test",
+		}).
+		countWhere(&client.CountWhereRequest{
+			TablePrefixWithSchema: tablePrefix,
+			Version:               "v1",
+			Where:                 client.NewClause().Equal("id", id),
 		}, &count).
 		assertEqual(int64(0), count, "数量不一致")
 }

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio