Skip to content

Commit

Permalink
fix: calling the Query API, check if the Command parameter is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Young Xu <[email protected]>
  • Loading branch information
xuthus5 committed Dec 8, 2024
1 parent 73d180f commit 37a94d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions opengemini/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ func checkDatabaseAndPolicy(database, retentionPolicy string) error {
}
return nil
}

func checkCommand(cmd string) error {
if len(cmd) == 0 {
return ErrEmptyCommand
}
return nil
}
4 changes: 4 additions & 0 deletions opengemini/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ type Query struct {

// Query sends a command to the server
func (c *client) Query(q Query) (*QueryResult, error) {
if err := checkCommand(q.Command); err != nil {
return nil, err
}

req := buildRequestDetails(c.config, func(req *requestDetails) {
req.queryValues.Add("db", q.Database)
req.queryValues.Add("q", q.Command)
Expand Down

0 comments on commit 37a94d4

Please sign in to comment.