-
Notifications
You must be signed in to change notification settings - Fork 81
Feature/add mis endpoints in query #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature/add mis endpoints in query #696
Conversation
… specified database
02974e4
to
f6a6c13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive query-related endpoints to the ArangoDB Go driver v2, implementing 16 missing API endpoints for query management and user-defined functions. The implementation provides full query system control including properties management, query monitoring, caching, optimization rules, and user-defined function operations.
- Adds query properties management endpoints (GET/PUT)
- Implements query monitoring and control endpoints (current/slow queries, kill operations)
- Adds query caching and plan cache management endpoints
- Includes optimizer rules and user-defined function endpoints
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
v2/utils/type.go | Adds ToJSONString utility function for JSON formatting |
v2/tests/database_query_test.go | Comprehensive test suite for all new query endpoints |
v2/arangodb/utils.go | Adds RequiredFieldError helper function |
v2/arangodb/database_query_impl.go | Complete implementation of all 16 query endpoints |
v2/arangodb/database_query.go | Interface definitions and data structures for query endpoints |
v2/CHANGELOG.md | Documents the addition of missing query endpoints |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
v2/arangodb/database_query_impl.go
Outdated
} | ||
|
||
func (d databaseQuery) KillAQLQuery(ctx context.Context, queryId string, all *bool) error { | ||
return d.deleteQueryEndpoint(ctx, path.Join("_api/query", queryId), all) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path.Join function is inappropriate for URL construction. It uses OS-specific path separators which could cause issues on Windows. Use strings.Join or manual string concatenation instead.
return d.deleteQueryEndpoint(ctx, path.Join("_api/query", queryId), all) | |
return d.deleteQueryEndpoint(ctx, "_api/query/" + queryId, all) |
Copilot uses AI. Check for mistakes.
v2/tests/database_query_test.go
Outdated
|
||
// If still empty, check if the feature is supported | ||
if len(resp) == 0 { | ||
t.Logf("Query plan cache is empty. This might be because:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message contains 'Query plan cache' but should be 'Query entries cache' to match the context of the test function Test_GetQueryEntriesCache.
t.Logf("Query plan cache is empty. This might be because:") | |
t.Logf("Query entries cache is empty. This might be because:") |
Copilot uses AI. Check for mistakes.
v2/tests/database_query_test.go
Outdated
// If still empty, check if the feature is supported | ||
if len(resp) == 0 { | ||
t.Logf("Query plan cache is empty. This might be because:") | ||
t.Logf("1. Query query entries caching is disabled in ArangoDB configuration") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log message contains redundant 'Query query entries' and should be 'Query entries caching is disabled in ArangoDB configuration'.
t.Logf("1. Query query entries caching is disabled in ArangoDB configuration") | |
t.Logf("1. Query entries caching is disabled in ArangoDB configuration") |
Copilot uses AI. Check for mistakes.
v2/arangodb/database_query_impl.go
Outdated
|
||
resp, err := connection.CallDelete(ctx, d.db.connection(), url, &response, d.db.modifiers...) | ||
if err != nil { | ||
return utils.NewType(0), err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an error occurs during the HTTP call, returning utils.NewType(0) masks the actual error condition. Consider returning nil instead to indicate no deletion count is available due to the error.
return utils.NewType(0), err | |
return nil, err |
Copilot uses AI. Check for mistakes.
v2/arangodb/database_query_impl.go
Outdated
case http.StatusOK, http.StatusCreated: | ||
return response.DeletedCount, nil | ||
default: | ||
return utils.NewType(0), response.AsArangoErrorWithCode(code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a non-success HTTP status is returned, returning utils.NewType(0) provides misleading information that 0 functions were deleted. Consider returning nil to indicate the operation failed.
return utils.NewType(0), response.AsArangoErrorWithCode(code) | |
return nil, err | |
} | |
switch code := resp.Code(); code { | |
case http.StatusOK, http.StatusCreated: | |
return response.DeletedCount, nil | |
default: | |
return nil, response.AsArangoErrorWithCode(code) |
Copilot uses AI. Check for mistakes.
This includes the following Query-related endpoints: