Przeglądaj źródła

完成clause添加

yjp 3 miesięcy temu
rodzic
commit
f2c33bd269
5 zmienionych plików z 324 dodań i 132 usunięć
  1. 65 0
      client/clause.go
  2. 15 15
      client/client_query_request.go
  3. 0 9
      client/condition.go
  4. 224 84
      dpsv1/client.go
  5. 20 24
      test/v1/v1_test.go

+ 65 - 0
client/clause.go

@@ -0,0 +1,65 @@
+package client
+
+import "encoding/json"
+
+type Clause struct {
+	queryAndArgsPars map[string][]any
+}
+
+func NewClause() *Clause {
+	return &Clause{queryAndArgsPars: make(map[string][]any)}
+}
+
+func (clause *Clause) Common(query string, args ...any) *Clause {
+	clause.queryAndArgsPars[query] = args
+	return clause
+}
+
+func (clause *Clause) Equal(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" = ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) Like(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" LIKE ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) In(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" IN ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) NotIn(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" NOT IN ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) Not(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" != ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) LessThan(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" < ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) LessThanAndEqual(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" <= ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) GreaterThan(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" > ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) GreaterThanAndEqual(columnName string, value any) *Clause {
+	clause.queryAndArgsPars[columnName+" >= ?"] = []any{value}
+	return clause
+}
+
+func (clause *Clause) ToJson() ([]byte, error) {
+	return json.Marshal(clause.queryAndArgsPars)
+}

+ 15 - 15
client/client_query_request.go

@@ -3,8 +3,8 @@ package client
 type QueryByWhereAndOrderByRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	Select                map[string][]any
-	Where                 map[string][]any
+	Select                *Clause
+	Where                 *Clause
 	OrderBy               []string
 	PageNo                int
 	PageSize              int
@@ -13,13 +13,13 @@ type QueryByWhereAndOrderByRequest struct {
 type CommonQueryRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	Select                map[string][]any
-	Where                 map[string][]any
+	Select                *Clause
+	Where                 *Clause
 	OrderBy               []string
-	Or                    map[string][]any
+	Or                    *Clause
 	GroupBy               []string
-	Joins                 map[string][]any
-	Having                map[string][]any
+	Joins                 *Clause
+	Having                *Clause
 	PageNo                int
 	PageSize              int
 }
@@ -27,29 +27,29 @@ type CommonQueryRequest struct {
 type QueryByKeysRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	Select                map[string][]any
+	Select                *Clause
 	KeyValues             map[string]string
 }
 
 type CountWhereRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	Where                 map[string][]any
+	Where                 *Clause
 }
 
 type CommonCountRequest struct {
 	TablePrefixWithSchema string
 	Version               string
-	Where                 map[string][]any
-	Or                    map[string][]any
+	Where                 *Clause
+	Or                    *Clause
 	GroupBy               []string
-	Joins                 map[string][]any
-	Having                map[string][]any
+	Joins                 *Clause
+	Having                *Clause
 }
 
 type EventQueryByKeysRequest struct {
 	TablePrefixWithSchema string
-	Select                map[string][]any
+	Select                *Clause
 	KeyValues             []string
 	PageNo                int
 	PageSize              int
@@ -57,7 +57,7 @@ type EventQueryByKeysRequest struct {
 
 type CommonEventQueryRequest struct {
 	TablePrefixWithSchema string
-	Select                map[string][]any
+	Select                *Clause
 	KeyValues             []string
 	Version               string
 	Operation             string

+ 0 - 9
client/condition.go

@@ -1,9 +0,0 @@
-package client
-
-type Condition struct {
-	queryAndArgsPars map[string][]any
-}
-
-func NewCondition() {
-
-}

+ 224 - 84
dpsv1/client.go

@@ -278,14 +278,24 @@ func (c *Client) Replay(req *client.ReplayRequest) (string, error) {
 }
 
 func (c *Client) QueryByWhereAndOrderBy(req *client.QueryByWhereAndOrderByRequest) (string, []client.TableRow, int64, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, 0, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
-	whereJsonBytes, err := json.Marshal(req.Where)
-	if err != nil {
-		return "", nil, 0, err
+	var whereJsonBytes []byte
+	if req.Where != nil {
+		innerJsonBytes, err := req.Where.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		whereJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.QueryByWhereAndOrderBy(context.Background(), &request.QueryByWhereAndOrderByRequest{
@@ -311,29 +321,54 @@ func (c *Client) QueryByWhereAndOrderBy(req *client.QueryByWhereAndOrderByReques
 }
 
 func (c *Client) CommonQuery(req *client.CommonQueryRequest) (string, []client.TableRow, int64, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, 0, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
-	whereJsonBytes, err := json.Marshal(req.Where)
-	if err != nil {
-		return "", nil, 0, err
+	var whereJsonBytes []byte
+	if req.Where != nil {
+		innerJsonBytes, err := req.Where.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		whereJsonBytes = innerJsonBytes
 	}
 
-	orJsonBytes, err := json.Marshal(req.Or)
-	if err != nil {
-		return "", nil, 0, err
+	var orJsonBytes []byte
+	if req.Or != nil {
+		innerJsonBytes, err := req.Or.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		orJsonBytes = innerJsonBytes
 	}
 
-	joinsJsonBytes, err := json.Marshal(req.Joins)
-	if err != nil {
-		return "", nil, 0, err
+	var joinsJsonBytes []byte
+	if req.Joins != nil {
+		innerJsonBytes, err := req.Joins.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		joinsJsonBytes = innerJsonBytes
 	}
 
-	havingJsonBytes, err := json.Marshal(req.Having)
-	if err != nil {
-		return "", nil, 0, err
+	var havingJsonBytes []byte
+	if req.Having != nil {
+		innerJsonBytes, err := req.Having.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		havingJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.CommonQuery(context.Background(), &request.CommonQueryRequest{
@@ -363,14 +398,24 @@ func (c *Client) CommonQuery(req *client.CommonQueryRequest) (string, []client.T
 }
 
 func (c *Client) QueryOnlyByWhereAndOrderBy(req *client.QueryByWhereAndOrderByRequest) (string, []client.TableRow, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
-	whereJsonBytes, err := json.Marshal(req.Where)
-	if err != nil {
-		return "", nil, err
+	var whereJsonBytes []byte
+	if req.Where != nil {
+		innerJsonBytes, err := req.Where.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		whereJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.QueryOnlyByWhereAndOrderBy(context.Background(), &request.QueryByWhereAndOrderByRequest{
@@ -396,29 +441,54 @@ func (c *Client) QueryOnlyByWhereAndOrderBy(req *client.QueryByWhereAndOrderByRe
 }
 
 func (c *Client) CommonQueryOnly(req *client.CommonQueryRequest) (string, []client.TableRow, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
-	whereJsonBytes, err := json.Marshal(req.Where)
-	if err != nil {
-		return "", nil, err
+	var whereJsonBytes []byte
+	if req.Where != nil {
+		innerJsonBytes, err := req.Where.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		whereJsonBytes = innerJsonBytes
 	}
 
-	orJsonBytes, err := json.Marshal(req.Or)
-	if err != nil {
-		return "", nil, err
+	var orJsonBytes []byte
+	if req.Or != nil {
+		innerJsonBytes, err := req.Or.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		orJsonBytes = innerJsonBytes
 	}
 
-	joinsJsonBytes, err := json.Marshal(req.Joins)
-	if err != nil {
-		return "", nil, err
+	var joinsJsonBytes []byte
+	if req.Joins != nil {
+		innerJsonBytes, err := req.Joins.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		joinsJsonBytes = innerJsonBytes
 	}
 
-	havingJsonBytes, err := json.Marshal(req.Having)
-	if err != nil {
-		return "", nil, err
+	var havingJsonBytes []byte
+	if req.Having != nil {
+		innerJsonBytes, err := req.Having.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		havingJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.CommonQueryOnly(context.Background(), &request.CommonQueryRequest{
@@ -448,9 +518,14 @@ func (c *Client) CommonQueryOnly(req *client.CommonQueryRequest) (string, []clie
 }
 
 func (c *Client) QueryByKeys(req *client.QueryByKeysRequest) (string, *client.TableRow, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.QueryByKeys(context.Background(), &request.QueryByKeysRequest{
@@ -474,9 +549,14 @@ func (c *Client) QueryByKeys(req *client.QueryByKeysRequest) (string, *client.Ta
 }
 
 func (c *Client) CountWhere(req *client.CountWhereRequest) (string, int64, error) {
-	whereJsonBytes, err := json.Marshal(req.Where)
-	if err != nil {
-		return "", 0, err
+	var whereJsonBytes []byte
+	if req.Where != nil {
+		innerJsonBytes, err := req.Where.ToJson()
+		if err != nil {
+			return "", 0, err
+		}
+
+		whereJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.CountWhere(context.Background(), &request.CountWhereRequest{
@@ -493,24 +573,44 @@ func (c *Client) CountWhere(req *client.CountWhereRequest) (string, int64, error
 }
 
 func (c *Client) CommonCount(req *client.CommonCountRequest) (string, int64, error) {
-	whereJsonBytes, err := json.Marshal(req.Where)
-	if err != nil {
-		return "", 0, err
+	var whereJsonBytes []byte
+	if req.Where != nil {
+		innerJsonBytes, err := req.Where.ToJson()
+		if err != nil {
+			return "", 0, err
+		}
+
+		whereJsonBytes = innerJsonBytes
 	}
 
-	orJsonBytes, err := json.Marshal(req.Or)
-	if err != nil {
-		return "", 0, err
+	var orJsonBytes []byte
+	if req.Or != nil {
+		innerJsonBytes, err := req.Or.ToJson()
+		if err != nil {
+			return "", 0, err
+		}
+
+		orJsonBytes = innerJsonBytes
 	}
 
-	joinsJsonBytes, err := json.Marshal(req.Joins)
-	if err != nil {
-		return "", 0, err
+	var joinsJsonBytes []byte
+	if req.Joins != nil {
+		innerJsonBytes, err := req.Joins.ToJson()
+		if err != nil {
+			return "", 0, err
+		}
+
+		joinsJsonBytes = innerJsonBytes
 	}
 
-	havingJsonBytes, err := json.Marshal(req.Having)
-	if err != nil {
-		return "", 0, err
+	var havingJsonBytes []byte
+	if req.Having != nil {
+		innerJsonBytes, err := req.Having.ToJson()
+		if err != nil {
+			return "", 0, err
+		}
+
+		havingJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.queryServiceClient.CommonCount(context.Background(), &request.CommonCountRequest{
@@ -531,9 +631,14 @@ func (c *Client) CommonCount(req *client.CommonCountRequest) (string, int64, err
 }
 
 func (c *Client) EventQueryByKeys(req *client.EventQueryByKeysRequest) (string, []client.EventInfo, int64, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, 0, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.EventQueryByKeys(context.Background(), &request.EventQueryByKeysRequest{
@@ -552,9 +657,14 @@ func (c *Client) EventQueryByKeys(req *client.EventQueryByKeysRequest) (string,
 }
 
 func (c *Client) CommonEventQuery(req *client.CommonEventQueryRequest) (string, []client.EventInfo, int64, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, 0, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.CommonEventQuery(context.Background(), &request.CommonEventQueryRequest{
@@ -578,9 +688,14 @@ func (c *Client) CommonEventQuery(req *client.CommonEventQueryRequest) (string,
 }
 
 func (c *Client) EventQueryOnlyByKeys(req *client.EventQueryByKeysRequest) (string, []client.EventInfo, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.EventQueryOnlyByKeys(context.Background(), &request.EventQueryByKeysRequest{
@@ -599,9 +714,14 @@ func (c *Client) EventQueryOnlyByKeys(req *client.EventQueryByKeysRequest) (stri
 }
 
 func (c *Client) CommonEventQueryOnly(req *client.CommonEventQueryRequest) (string, []client.EventInfo, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.CommonEventQueryOnly(context.Background(), &request.CommonEventQueryRequest{
@@ -656,9 +776,14 @@ func (c *Client) CommonCountEvent(req *client.CommonCountEventRequest) (string,
 }
 
 func (c *Client) EventHistoryQueryByKeys(req *client.EventQueryByKeysRequest) (string, []client.EventInfo, int64, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, 0, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.EventHistoryQueryByKeys(context.Background(), &request.EventQueryByKeysRequest{
@@ -677,9 +802,14 @@ func (c *Client) EventHistoryQueryByKeys(req *client.EventQueryByKeysRequest) (s
 }
 
 func (c *Client) CommonEventHistoryQuery(req *client.CommonEventQueryRequest) (string, []client.EventInfo, int64, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, 0, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, 0, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.CommonEventHistoryQuery(context.Background(), &request.CommonEventQueryRequest{
@@ -703,9 +833,14 @@ func (c *Client) CommonEventHistoryQuery(req *client.CommonEventQueryRequest) (s
 }
 
 func (c *Client) EventHistoryQueryOnlyByKeys(req *client.EventQueryByKeysRequest) (string, []client.EventInfo, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.EventHistoryQueryOnlyByKeys(context.Background(), &request.EventQueryByKeysRequest{
@@ -724,9 +859,14 @@ func (c *Client) EventHistoryQueryOnlyByKeys(req *client.EventQueryByKeysRequest
 }
 
 func (c *Client) CommonEventHistoryQueryOnly(req *client.CommonEventQueryRequest) (string, []client.EventInfo, error) {
-	selectJsonBytes, err := json.Marshal(req.Select)
-	if err != nil {
-		return "", nil, err
+	var selectJsonBytes []byte
+	if req.Select != nil {
+		innerJsonBytes, err := req.Select.ToJson()
+		if err != nil {
+			return "", nil, err
+		}
+
+		selectJsonBytes = innerJsonBytes
 	}
 
 	reply, err := c.eventQueryServiceClient.CommonEventHistoryQueryOnly(context.Background(), &request.CommonEventQueryRequest{

+ 20 - 24
test/v1/v1_test.go

@@ -161,9 +161,7 @@ func TestTransaction(t *testing.T) {
 		countWhere(&client.CountWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ?": {id},
-			},
+			Where:                 client.NewClause().Equal("id", id),
 		}, &count).
 		assertEqual(int64(0), count, "数量不一致")
 }
@@ -270,17 +268,13 @@ func TestTransactionBatch(t *testing.T) {
 		countWhere(&client.CountWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ?": {id1},
-			},
+			Where:                 client.NewClause().Equal("id", id1),
 		}, &count).
 		assertEqual(int64(0), count, "数量不一致").
 		countWhere(&client.CountWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ?": {id2},
-			},
+			Where:                 client.NewClause().Equal("id", id2),
 		}, &count).
 		assertEqual(int64(0), count, "数量不一致")
 }
@@ -383,9 +377,10 @@ func TestInsertBatch(t *testing.T) {
 		queryByWhereAndOrderBy(&client.QueryByWhereAndOrderByRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ? AND name = ? AND table_num = ?": {id1, name1, tableNum1},
-			},
+			Where: client.NewClause().
+				Equal("id", id1).
+				Equal("name", name1).
+				Equal("table_num", tableNum1),
 			PageNo:   1,
 			PageSize: 1,
 		}, &resultTableRows, &totalCount).
@@ -397,9 +392,10 @@ func TestInsertBatch(t *testing.T) {
 		commonQuery(&client.CommonQueryRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ? AND name = ? AND table_num = ?": {id2, name2, tableNum2},
-			},
+			Where: client.NewClause().
+				Equal("id", id2).
+				Equal("name", name2).
+				Equal("table_num", tableNum2),
 			PageNo:   1,
 			PageSize: 1,
 		}, &resultTableRows, &totalCount).
@@ -411,9 +407,10 @@ func TestInsertBatch(t *testing.T) {
 		queryOnlyByWhereAndOrderBy(&client.QueryByWhereAndOrderByRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ? AND name = ? AND table_num = ?": {id1, name1, tableNum1},
-			},
+			Where: client.NewClause().
+				Equal("id", id1).
+				Equal("name", name1).
+				Equal("table_num", tableNum1),
 			PageNo:   1,
 			PageSize: 1,
 		}, &resultTableRows).
@@ -424,9 +421,10 @@ func TestInsertBatch(t *testing.T) {
 		commonQueryOnly(&client.CommonQueryRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ? AND name = ? AND table_num = ?": {id2, name2, tableNum2},
-			},
+			Where: client.NewClause().
+				Equal("id", id2).
+				Equal("name", name2).
+				Equal("table_num", tableNum2),
 			PageNo:   1,
 			PageSize: 1,
 		}, &resultTableRows).
@@ -538,9 +536,7 @@ func TestDelete(t *testing.T) {
 		countWhere(&client.CountWhereRequest{
 			TablePrefixWithSchema: tablePrefix,
 			Version:               "v1",
-			Where: map[string][]any{
-				"id = ?": {id},
-			},
+			Where:                 client.NewClause().Equal("id", id),
 		}, &count).
 		assertEqual(int64(0), count, "数量不一致")
 }